Showing the changes to interface/src/scripting/OSCScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -181,11 +181,14 @@ OSCScriptingInterface::OSCScriptingInterface(QObject* parent) : · 180 unmodified lines | |||
| 181 | _sendHost("osc/sendHost", "127.0.0.1"), | 181 | _sendHost("osc/sendHost", "127.0.0.1"), |
| 182 | _socket(std::make_shared<QUdpSocket>(this)) | 182 | _socket(std::make_shared<QUdpSocket>(this)) |
| 183 | { | 183 | { |
| 184 | _socket->bind(QHostAddress(_receiveHost.get()), _receivePort.get()); | 184 | connect(_socket.get(), &QUdpSocket::readyRead, this, [this] { |
| 185 | 185 | // multiple datagrams might arrive at once | |
| 186 | connect(_socket.get(), &QUdpSocket::readyRead, this, &OSCScriptingInterface::readPacket); | 186 | while (_socket->hasPendingDatagrams()) { |
| 187 | readPacket(); | ||
| 188 | } | ||
| 189 | }); | ||
| 187 | 190 | ||
| 188 | qCInfo(osc_cat) << "Listening on" << _socket->localAddress() << ":" << _socket->localPort(); | 191 | rebindSocket(); |
| 189 | } | 192 | } |
| 190 | 193 | ||
| 191 | OSCScriptingInterface::~OSCScriptingInterface() { | 194 | OSCScriptingInterface::~OSCScriptingInterface() { |
| @@ -361,7 +364,6 @@ ScriptValue OSCScriptingInterface::sendPacket(ScriptContext* context, ScriptEngi · 169 unmodified lines | |||
| 361 | arguments.append(context->argument(i).toVariant()); | 364 | arguments.append(context->argument(i).toVariant()); |
| 362 | } | 365 | } |
| 363 | 366 | ||
| 364 | |||
| 365 | if (address == "#bundle") { | 367 | if (address == "#bundle") { |
| 366 | engine->raiseException("OSC bundles are not supported"); | 368 | engine->raiseException("OSC bundles are not supported"); |
| 367 | return engine->undefinedValue(); | 369 | return engine->undefinedValue(); |
| @@ -473,8 +475,6 @@ ScriptValue OSCScriptingInterface::sendPacket(ScriptContext* context, ScriptEngi · 105 unmodified lines | |||
| 473 | 475 | ||
| 474 | instance->_socket->writeDatagram(bytes, QHostAddress(instance->_sendHost.get()), instance->_sendPort.get()); | 476 | instance->_socket->writeDatagram(bytes, QHostAddress(instance->_sendHost.get()), instance->_sendPort.get()); |
| 475 | 477 | ||
| 476 | qCDebug(osc_cat) << QHostAddress(instance->_sendHost.get()) << instance->_sendPort.get() << ":" << bytes.toHex(' '); | ||
| 477 | |||
| 478 | return engine->undefinedValue(); | 478 | return engine->undefinedValue(); |
| 479 | } | 479 | } |
| 480 | 480 | ||