2024-04-02 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in the PAD subsystem that caused meta-events to be
	included in the update events.
	* Refactored the PAD subsystem to use native Qt JSON methods.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2024-04-02 17:42:04 -04:00
parent baec002fd0
commit 68bd802bd0
6 changed files with 150 additions and 126 deletions

View File

@@ -30,6 +30,8 @@
MetadataSource::MetadataSource(QTcpSocket *sock)
{
meta_socket=sock;
meta_curly_count=0;
meta_quoted=false;
meta_committed=true;
}
@@ -46,7 +48,24 @@ bool MetadataSource::appendBuffer(const QByteArray &data)
meta_buffer.clear();
}
meta_buffer+=data;
meta_committed=meta_buffer.endsWith("\r\n\r\n");
for(int i=0;i<data.size();i++) {
if(data.at(i)=='"') {
meta_quoted=!meta_quoted;
}
if(!meta_quoted) {
if(data.at(i)=='{') {
meta_curly_count++;
}
if(data.at(i)=='}') {
meta_curly_count--;
}
}
}
meta_committed=(meta_curly_count==0);
if(meta_committed) {
meta_buffer+="\n\n";
}
return meta_committed;
}
@@ -195,7 +214,7 @@ void Repeater::SendState(int id)
{
for(QMap<int,MetadataSource *>::const_iterator it=pad_sources.begin();
it!=pad_sources.end();it++) {
if(it.value()->isCommitted()) {
if(it.value()->isCommitted()&&(!it.value()->buffer().trimmed().isEmpty())) {
pad_client_sockets.value(id)->write(it.value()->buffer());
}
}

View File

@@ -2,7 +2,7 @@
//
// Rivendell PAD Data Repeater
//
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-2024 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -42,6 +42,8 @@ class MetadataSource
private:
QByteArray meta_buffer;
int meta_curly_count;
bool meta_quoted;
bool meta_committed;
QTcpSocket *meta_socket;
};