summaryrefslogtreecommitdiffstats
path: root/src/net/mcast/McastReceiver.cpp
diff options
context:
space:
mode:
authorSebastien Braun2010-07-19 11:53:55 +0200
committerSebastien Braun2010-07-19 11:53:55 +0200
commit755f07b1a25c414b0c7cbe28db4a7ecbc32975c7 (patch)
treea9dc99869865bc0f1f0b3e19c488459b3bc8a7fd /src/net/mcast/McastReceiver.cpp
parentRemember to delete outgoing transfers when they are finished or failed (diff)
downloadpvs-755f07b1a25c414b0c7cbe28db4a7ecbc32975c7.tar.gz
pvs-755f07b1a25c414b0c7cbe28db4a7ecbc32975c7.tar.xz
pvs-755f07b1a25c414b0c7cbe28db4a7ecbc32975c7.zip
Implement initial multicast receive functionality in PVS daemon
Diffstat (limited to 'src/net/mcast/McastReceiver.cpp')
-rw-r--r--src/net/mcast/McastReceiver.cpp49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/net/mcast/McastReceiver.cpp b/src/net/mcast/McastReceiver.cpp
index 6070208..1f27127 100644
--- a/src/net/mcast/McastReceiver.cpp
+++ b/src/net/mcast/McastReceiver.cpp
@@ -27,7 +27,7 @@
McastReceiver::McastReceiver(QIODevice* iodev, McastConfiguration* config, QObject* parent) :
QObject(parent),
- _config(config ? new McastConfiguration(*config) : new McastConfiguration()),
+ _config(config ? new McastConfiguration(*config) : 0),
_socket(0),
_curoffs(0),
_closed(false),
@@ -43,13 +43,52 @@ McastReceiver::~McastReceiver()
delete _config;
}
-void McastReceiver::start()
+void McastReceiver::config(McastConfiguration const* config)
{
+ if (_config)
+ delete _config;
+ _config = new McastConfiguration(*config, this);
+}
+
+bool McastReceiver::start()
+{
+ McastConfiguration *config = _config;
+ if (!config)
+ config = new McastConfiguration();
+
+ if (_socket)
+ {
+ delete _socket;
+ }
_socket = new McastPGMSocket(this);
- connect(_socket, SIGNAL(receivedPacket(QByteArray)), this, SLOT(receivedPacket(QByteArray)));
- connect(_socket, SIGNAL(connectionReset()), this, SLOT(connectionReset()));
+
+ connect(_socket, SIGNAL(receivedPacket(QByteArray)), SLOT(receivedPacket(QByteArray)));
+ connect(_socket, SIGNAL(connectionReset()), SLOT(connectionReset()));
// connect(_socket, SIGNAL(connectionFinished()), this, SLOT(connectionFinished()));
- _socket->open(_config, McastPGMSocket::PSOCK_READ);
+ if (_socket->open(_config, McastPGMSocket::PSOCK_READ))
+ {
+ return true;
+ }
+ else
+ {
+ disconnect(_socket, SIGNAL(receivedPacket(QByteArray)), this, SLOT(receivedPacket(QByteArray)));
+ disconnect(_socket, SIGNAL(connectionReset()), this, SLOT(connectionReset()));
+ return false;
+ }
+}
+
+void McastReceiver::abort()
+{
+ if (_socket)
+ {
+ delete _socket;
+ _socket = 0;
+ }
+
+ if (_iodev)
+ {
+ _iodev->close();
+ }
}
void McastReceiver::receivedPacket(QByteArray const& bytes)