diff options
Diffstat (limited to 'src/net/mcast/McastReceiver.cpp')
| -rw-r--r-- | src/net/mcast/McastReceiver.cpp | 49 |
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) |
