void FrameLoaderClientBlackBerry::committedLoad(DocumentLoader* loader, const char* data, int length) { // The structure of this code may seem...a bit odd. It's structured with two checks on the state // of m_pluginView because it's actually receivedData that may cause the request to re-direct data // to a PluginView. This is because receivedData may decide to create a PluginDocument containing // a PluginView. The PluginView will request that the main resource for the frame be redirected // to the PluginView. So after receivedData has been called, this code needs to check whether // re-direction to a PluginView has been requested and pass the same data on to the PluginView. // Thereafter, all data will be re-directed to the PluginView; i.e., no additional data will go // to receivedData. if (!m_pluginView) { const String& textEncoding = loader->response().textEncodingName(); receivedData(data, length, textEncoding); } if (m_pluginView) { if (!m_hasSentResponseToPlugin) { m_pluginView->didReceiveResponse(loader->response()); m_hasSentResponseToPlugin = true; } if (!m_pluginView) return; m_pluginView->didReceiveData(data, length); } }
void AutoConnection::requestFinished(QNetworkReply *reply) { if (status == FinishedWork) return; reply->deleteLater(); if (reply->error() == QNetworkReply::NoError) { requests.remove(reply); mtpBuffer data = HTTPConnection::handleResponse(reply); if (data.size() == 1) { if (status == WaitingBoth) { status = WaitingTcp; } else { emit error(); } } else if (!data.isEmpty()) { if (status == UsingHttp) { receivedQueue.push_back(data); emit receivedData(); } else if (status == WaitingBoth || status == WaitingHttp) { try { auto res_pq = readPQFakeReply(data); const auto &res_pq_data(res_pq.c_resPQ()); if (res_pq_data.vnonce == httpNonce) { if (status == WaitingBoth) { status = HttpReady; httpStartTimer.start(MTPTcpConnectionWaitTimeout); } else { DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by pq-response, awaited").arg((_flagsHttp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4")); status = UsingHttp; sock.disconnectFromHost(); emit connected(); } } } catch (Exception &e) { DEBUG_LOG(("Connection Error: exception in parsing HTTP fake pq-responce, %1").arg(e.what())); if (status == WaitingBoth) { status = WaitingTcp; } else { emit error(); } } } else if (status == UsingTcp) { DEBUG_LOG(("Connection Info: already using tcp, ignoring http response")); } } } else { if (!requests.remove(reply)) { return; } bool mayBeBadKey = HTTPConnection::handleError(reply) && _sentEncrypted; if (status == WaitingBoth) { status = WaitingTcp; } else if (status == WaitingHttp || status == UsingHttp) { emit error(mayBeBadKey); } else { LOG(("Strange Http Error: status %1").arg(status)); } } }
int Konsole::Pty::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = K3Process::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: done((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: receivedData((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 2: bufferEmpty(); break; case 3: readRVBData(); break; case 4: setUtf8Mode((*reinterpret_cast< bool(*)>(_a[1]))); break; case 5: lockPty((*reinterpret_cast< bool(*)>(_a[1]))); break; case 6: sendData((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 7: sendData1((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 8: doSendJobs1(); break; case 9: donePty(); break; case 10: dataReceived((*reinterpret_cast< K3Process*(*)>(_a[1])),(*reinterpret_cast< char*(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 11: doSendJobs(); break; case 12: writeReady(); break; default: ; } _id -= 13; } return _id; }
// _____________________________________________________________________ void CWebSocketServer::processMessage(QString message) { QWebSocket *pSender = qobject_cast<QWebSocket *>(sender()); if (m_clients.contains(pSender)) { int cliend_id = m_clients[pSender]; emit (receivedData(cliend_id, message.toStdString().c_str())); } }
void QtUdpSocketPlugin::onConnect(QString ip, quint16 port) { _socket = new QUdpSocket(this); _socket->setReadBufferSize(UDP_BUFFER_SIZE); _socket->bind(QHostAddress::Any, port); _targetHost = ip; _targetPort = port + 1; QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(receivedData())); }
// _____________________________________________________________________ void CWebSocketServer::processMessage(QByteArray message) { QWebSocket *pSender = qobject_cast<QWebSocket *>(sender()); if (m_clients.contains(pSender)) { int cliend_id = m_clients[pSender]; emit (receivedData(cliend_id, message)); } }
void AutoConnection::socketPacket(const char *packet, uint32 length) { if (status == FinishedWork) return; mtpBuffer data = AbstractTCPConnection::handleResponse(packet, length); if (data.size() == 1) { if (status == WaitingBoth) { status = WaitingHttp; sock.disconnectFromHost(); } else if (status == HttpReady) { DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by bad tcp response, ready").arg((_flagsHttp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4")); status = UsingHttp; sock.disconnectFromHost(); emit connected(); } else if (status == WaitingTcp || status == UsingTcp) { bool mayBeBadKey = (data[0] == -410) && _sentEncrypted; emit error(mayBeBadKey); } else { LOG(("Strange Tcp Error; status %1").arg(status)); } } else if (status == UsingTcp) { receivedQueue.push_back(data); emit receivedData(); } else if (status == WaitingBoth || status == WaitingTcp || status == HttpReady) { tcpTimeoutTimer.stop(); try { auto res_pq = readPQFakeReply(data); const auto &res_pq_data(res_pq.c_resPQ()); if (res_pq_data.vnonce == tcpNonce) { DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flagsTcp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4")); status = UsingTcp; emit connected(); } } catch (Exception &e) { DEBUG_LOG(("Connection Error: exception in parsing TCP fake pq-responce, %1").arg(e.what())); if (status == WaitingBoth) { status = WaitingHttp; sock.disconnectFromHost(); } else if (status == HttpReady) { DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by bad tcp response, awaited").arg((_flagsHttp & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4")); status = UsingHttp; sock.disconnectFromHost(); emit connected(); } else { emit error(); } } } }
void MainServer::onNewUserConnected() { Client client; client.socket = server->nextPendingConnection(); client.status = ST_CONNECTED; client.playingWith = clients.end(); int clientId = client.socket->socketDescriptor(); clients.insert( clientId, client ); connect( client.socket, SIGNAL( readyRead() ), this, SLOT( receivedData() ) ); qDebug() << "Client connected"; }
void UIDownloaderExtensionPack::handleDownloadedObject(UINetworkReply *pReply) { /* Read received data into the buffer: */ QByteArray receivedData(pReply->readAll()); /* Serialize that buffer into the file: */ while (true) { /* Try to open file for writing: */ QFile file(target()); if (file.open(QIODevice::WriteOnly)) { /* Write buffer into the file: */ file.write(receivedData); file.close(); /* Calc the SHA-256 on the bytes, creating a string: */ uint8_t abHash[RTSHA256_HASH_SIZE]; RTSha256(receivedData.constData(), receivedData.length(), abHash); char szDigest[RTSHA256_DIGEST_LEN + 1]; int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest)); if (RT_FAILURE(rc)) { AssertRC(rc); szDigest[0] = '\0'; } /* Warn the listener about extension-pack was downloaded: */ emit sigDownloadFinished(source().toString(), target(), &szDigest[0]); break; } /* Warn the user about extension-pack was downloaded but was NOT saved: */ msgCenter().warnAboutExtentionPackCantBeSaved(GUI_ExtPackName, source().toString(), QDir::toNativeSeparators(target())); /* Ask the user for another location for the extension-pack file: */ QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(), msgCenter().networkManagerOrMainWindowShown(), tr("Select folder to save %1 to").arg(GUI_ExtPackName), true); /* Check if user had really set a new target: */ if (!strTarget.isNull()) setTarget(QDir(strTarget).absoluteFilePath(QFileInfo(target()).fileName())); else break; } }
void StreamInfo::gotReply(QNetworkReply* reply) { StrAbstractor receivedData(QString(reply->readAll())); const QString status = receivedData.midStr("status=\"", "\""); if ( status == "fail" ) { emit error(); return; } const QString& broadID = receivedData.midStr("<request_id>lv", "</request_id>"); const QString& title = receivedData.midStr("<title>", "</title>"); const QString& description = receivedData.midStr("<description>", "</description>"); const QString& communityID = receivedData.midStr("<default_community>co", "</default_community>"); emit got(broadID, title, description, communityID); }
SerialLogging::SerialLogging(MainWindow *mainWindow, QSerialPortInfo serialPortDevice, int baudRate, QSerialPort::DataBits dataBits, QSerialPort::Parity parity, QSerialPort::StopBits stopBits) { serialPort = new QSerialPort(serialPortDevice); // Open int ret = serialPort->open(QIODevice::ReadWrite); if (!ret) { qDebug() << "Serial port failed to open"; delete serialPort; Q_ASSERT(0); } else { // Open file fileName = mainWindow->getFileName(); if (fileName != "") { file.setFileName(fileName); ret = file.open(QIODevice::WriteOnly); if (!ret) { qDebug() << "File failed to open"; delete serialPort; Q_ASSERT(0); } } // Set start time startTime = QDateTime::currentDateTimeUtc(); // Configure serial port serialPort->setBaudRate(baudRate); serialPort->setDataBits(dataBits); serialPort->setParity(parity); serialPort->setStopBits(stopBits); connect(this, SIGNAL(serialPortOpened()), mainWindow, SLOT(serialPortConnected())); connect(this, SIGNAL(newDataReady(QByteArray, quint64)), mainWindow, SLOT(receivedData(QByteArray, quint64))); connect(this, SIGNAL(newTimeStamp(qint64)), mainWindow, SLOT(updateTimer(qint64))); emit serialPortOpened(); } // Connect signals connect(serialPort, SIGNAL(readyRead()), this, SLOT(readData())); connect(mainWindow, SIGNAL(baudRateChanged(int)), this, SLOT(on_baudRateUpdated(int))); connect(mainWindow, SIGNAL(dataBitsChanged(QSerialPort::DataBits)), this, SLOT(on_dataBitsUpdated(QSerialPort::DataBits))); connect(mainWindow, SIGNAL(parityChanged(QSerialPort::Parity)), this, SLOT(on_parityUpdated(QSerialPort::Parity))); connect(mainWindow, SIGNAL(stopBitsChanged(QSerialPort::StopBits)), this, SLOT(on_stopBitsUpdated(QSerialPort::StopBits))); }
void RemoteUser::parseJSON(){ qDebug() << "RemoteUser::parseJSON"; QScriptValue sc; QScriptEngine engine; sc = engine.evaluate("(" + QString(m_strResponseData) + ")"); // In new versions it may need to look like engine.evaluate(); if (sc.property("return_msg").toString().compare("OK") != 0){ qDebug() << "return msg is not ok"; emit error(); return; } this->m_strFTPPassword = sc.property("data").property("ftp_password").toString(); this->m_strFTPUsername = sc.property("data").property("ftp_user").toString(); qDebug() << "ftp-user:"******"ftp-password:" << m_strFTPPassword; emit receivedData(); }
SerialPlayback::SerialPlayback(MainWindow *mainWindow) : logPlaybackPeriod(10), fsmStatus(FSM_SYNC0) { fileName = mainWindow->getFileName(); fileName = "/Users/kenz/Desktop/1212.ser"; if (fileName != "") { loadFile(fileName); if (file.isOpen()) { // Set start time logTime = 0; logHeartbeat.start(logPlaybackPeriod); // Connect signals connect(&logHeartbeat, SIGNAL(timeout()), this, SLOT(on_timerTimeout())); connect(mainWindow, SIGNAL(playbackSpeedChanged(int)), this, SLOT(on_playbackSpeedChanged(int))); connect(this, SIGNAL(newDataReady(QByteArray, quint64)), mainWindow, SLOT(receivedData(QByteArray, quint64))); }
void HTTPConnection::requestFinished(QNetworkReply *reply) { if (status == FinishedWork) return; reply->deleteLater(); if (reply->error() == QNetworkReply::NoError) { requests.remove(reply); mtpBuffer data = handleResponse(reply); if (data.size() == 1) { emit error(); } else if (!data.isEmpty()) { if (status == UsingHttp) { receivedQueue.push_back(data); emit receivedData(); } else { try { auto res_pq = readPQFakeReply(data); const auto &res_pq_data(res_pq.c_resPQ()); if (res_pq_data.vnonce == httpNonce) { DEBUG_LOG(("Connection Info: HTTP/%1-transport connected by pq-response").arg((_flags & MTPDdcOption::Flag::f_ipv6) ? "IPv6" : "IPv4")); status = UsingHttp; emit connected(); } } catch (Exception &e) { DEBUG_LOG(("Connection Error: exception in parsing HTTP fake pq-responce, %1").arg(e.what())); emit error(); } } } } else { if (!requests.remove(reply)) { return; } bool mayBeBadKey = handleError(reply) && _sentEncrypted; emit error(mayBeBadKey); } }
void UIDownloaderUserManual::handleDownloadedObject(UINetworkReply *pReply) { /* Read received data into the buffer: */ QByteArray receivedData(pReply->readAll()); /* Serialize that buffer into the file: */ while (true) { /* Try to open file for writing: */ QFile file(target()); if (file.open(QIODevice::WriteOnly)) { /* Write buffer into the file: */ file.write(receivedData); file.close(); /* Warn the user about user-manual loaded and saved: */ msgCenter().warnAboutUserManualDownloaded(source().toString(), QDir::toNativeSeparators(target())); /* Warn the listener about user-manual was downloaded: */ emit sigDownloadFinished(target()); break; } /* Warn user about user-manual was downloaded but was NOT saved: */ msgCenter().cannotSaveUserManual(source().toString(), QDir::toNativeSeparators(target())); /* Ask the user for another location for the user-manual file: */ QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(), windowManager().networkManagerOrMainWindowShown(), tr("Select folder to save User Manual to"), true); /* Check if user had really set a new target: */ if (!strTarget.isNull()) setTarget(QDir(strTarget).absoluteFilePath(QFileInfo(target()).fileName())); else break; } }
void MainWindow::startSensorThread() { sensorThread = new SensorThread(); //QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), this, SLOT(printData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), this, SLOT(updateCursors(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::settingsWidget), SLOT(displayData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::homeWidget), SLOT(switchMenu(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::desktopWidget), SLOT(switchMenu(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::galleryWidget), SLOT(displayData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(connectionChanged(QString)), getWidget(WidgetType::loadingWidget), SLOT(updateSubtitle(QString))); QObject::connect(sensorThread, SIGNAL(initializationChanged(WidgetType)), this, SLOT(setActiveWidget(WidgetType))); QObject::connect(getWidget(WidgetType::homeWidget), SIGNAL(menuSelected(WidgetType)), this, SLOT(setActiveWidget(WidgetType))); QObject::connect(sensorThread, SIGNAL(finished()), sensorThread, SLOT(deleteLater())); for (int i = 0; i < widgetsList.size(); i++){ QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), widgetsList[i], SLOT(collapse(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(widgetsList[i], SIGNAL(returnHome(WidgetType)), this, SLOT(setActiveWidget(WidgetType)));} sensorThread->start(); }
void UIDownloaderAdditions::handleDownloadedObject(QNetworkReply *pReply) { /* Read received data: */ QByteArray receivedData(pReply->readAll()); /* Serialize the incoming buffer into the .iso image: */ while (true) { /* Try to open file to save image: */ QFile file(target()); if (file.open(QIODevice::WriteOnly)) { /* Write received data into the file: */ file.write(receivedData); file.close(); /* Warn user about additions image loaded and saved, propose to mount it: */ if (msgCenter().confirmMountAdditions(source(), QDir::toNativeSeparators(target()))) emit sigDownloadFinished(target()); break; } else { /* Warn user about additions image loaded but was not saved: */ msgCenter().warnAboutAdditionsCantBeSaved(target()); } /* Ask the user about additions image file save location: */ QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(), parentWidget(), tr("Select folder to save Guest Additions image to"), true); /* Check if user set new target: */ if (!strTarget.isNull()) setTarget(QDir(strTarget).absoluteFilePath(QFileInfo(target()).fileName())); else break; } }
void Talk2WatchInterface::onDataReived(const QString &_data) { qDebug() << "onDataReceived"; emit receivedData(_data); }
/******************************************************************************* ** ** Function: nativeLlcpConnectionlessSocket_doReceiveFrom ** ** Description: Receive data from a peer. ** e: JVM environment. ** o: Java object. ** linkMiu: max info unit ** ** Returns: LlcpPacket Java object. ** *******************************************************************************/ static jobject nativeLlcpConnectionlessSocket_doReceiveFrom (JNIEnv* e, jobject, jint linkMiu) { ALOGD ("%s: linkMiu = %d", __FUNCTION__, linkMiu); jobject llcpPacket = NULL; ScopedLocalRef<jclass> clsLlcpPacket(e, NULL); if (sConnlessRecvWaitingForData != JNI_FALSE) { ALOGD ("%s: Already waiting for incoming data", __FUNCTION__); return NULL; } sConnlessRecvBuf = (uint8_t*) malloc (linkMiu); if (sConnlessRecvBuf == NULL) { ALOGD ("%s: Failed to allocate %d bytes memory buffer", __FUNCTION__, linkMiu); return NULL; } sConnlessRecvLen = linkMiu; // Create the write semaphore if (sem_init (&sConnlessRecvSem, 0, 0) == -1) { ALOGE ("%s: semaphore creation failed (errno=0x%08x)", __FUNCTION__, errno); return connectionlessCleanup (); } sConnlessRecvWaitingForData = JNI_TRUE; // Wait for sConnlessRecvSem completion status if (sem_wait (&sConnlessRecvSem)) { ALOGE ("%s: Failed to wait for write semaphore (errno=0x%08x)", __FUNCTION__, errno); goto TheEnd; } // Create new LlcpPacket object if (nfc_jni_cache_object_local (e, "com/android/nfc/LlcpPacket", &(llcpPacket)) == -1) { ALOGE ("%s: Find LlcpPacket class error", __FUNCTION__); return connectionlessCleanup (); } // Get NativeConnectionless class object clsLlcpPacket.reset(e->GetObjectClass(llcpPacket)); if (e->ExceptionCheck()) { e->ExceptionClear(); ALOGE ("%s: Get Object class error", __FUNCTION__); return connectionlessCleanup (); } // Set Llcp Packet remote SAP jfieldID f; f = e->GetFieldID(clsLlcpPacket.get(), "mRemoteSap", "I"); e->SetIntField(llcpPacket, f, (jbyte) sConnlessRecvRemoteSap); // Set Llcp Packet Buffer ALOGD ("%s: Received Llcp packet buffer size = %d\n", __FUNCTION__, sConnlessRecvLen); f = e->GetFieldID(clsLlcpPacket.get(), "mDataBuffer", "[B"); { ScopedLocalRef<jbyteArray> receivedData(e, e->NewByteArray(sConnlessRecvLen)); e->SetByteArrayRegion(receivedData.get(), 0, sConnlessRecvLen, (jbyte*) sConnlessRecvBuf); e->SetObjectField(llcpPacket, f, receivedData.get()); } TheEnd: // TODO: should all the "return connectionlessCleanup()"s in this function jump here instead? connectionlessCleanup (); if (sem_destroy (&sConnlessRecvSem)) { ALOGE ("%s: Failed to destroy sConnlessRecvSem semaphore (errno=0x%08x)", __FUNCTION__, errno); } return llcpPacket; }
void TerminalModel::onReceiveBlock(const char* buf, int len ) { _emulation->receiveData( buf, len ); emit receivedData( QString::fromLatin1( buf, len ) ); }
void QtUdpSocketPlugin::onListen(quint16 port) { _socket = new QUdpSocket(this); _socket->setReadBufferSize(UDP_BUFFER_SIZE); QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(receivedData())); _socket->bind(QHostAddress::Any, port + 1); }
void PlayerManager::HandlePacket(RakNet::Packet *packet) { RakNet::BitStream receivedData(packet->data, packet->length, false); RakNetwork *network = m_Network; RakNetGUID remotePeerGUID = packet->guid; unsigned char type; receivedData.Read(type); if (type == ID_NEW_INCOMING_CONNECTION) { // Notify new peers about the existing players if (NetworkManager::ArbitratorIsLocal()) { for (auto it = PlayerRegistry::PlayersBegin(), end = PlayerRegistry::PlayersEnd(); it != end; ++it) { RakNet::BitStream newPlayerNotification; newPlayerNotification.Write0(); // Tell the peer that the player is on another system newPlayerNotification.Write(it->NetID); if (it->LocalIndex >= s_MaxLocalPlayers) newPlayerNotification.Write(it->GUID); // Remote player (relative to this arbitrator) else newPlayerNotification.Write(NetworkManager::GetNetwork()->GetLocalGUID()); // Local player network->Send( NetDestination(remotePeerGUID, false), !Timestamped, MTID_ADDPLAYER, &newPlayerNotification, MEDIUM_PRIORITY, RELIABLE_ORDERED, CID_SYSTEM); } } } else if (type == MTID_ADDPLAYER) { if (NetworkManager::ArbitratorIsLocal()) { // So we can tell the remote peer what requested player we are adding: unsigned int remotePlayerIndex; receivedData.Read(remotePlayerIndex); PlayerID netId = m_NextNetId++;//m_UnusedNetIds.getFreeID(); PlayerRegistry::AddRemotePlayer(netId, remotePeerGUID); { RakNet::BitStream response; response.Write1(); // Tell the peer that the player being added is on their system response.Write(netId); response.Write(remotePlayerIndex); network->Send( NetDestination(remotePeerGUID, false), !Timestamped, MTID_ADDPLAYER, &response, MEDIUM_PRIORITY, RELIABLE_ORDERED, CID_SYSTEM); } { RakNet::BitStream newPlayerNotification; newPlayerNotification.Write0(); // Tell the peer that the player being added is on another system newPlayerNotification.Write(netId); newPlayerNotification.Write(remotePeerGUID); network->Send( NetDestination(remotePeerGUID, true), // Broadcast !Timestamped, MTID_ADDPLAYER, &newPlayerNotification, MEDIUM_PRIORITY, RELIABLE_ORDERED, CID_SYSTEM); } } else { bool localPlayer = receivedData.ReadBit(); // The net ID the arbiter has assigned to the new player: PlayerID netId; receivedData.Read(netId); if (localPlayer) { unsigned int localIndex; receivedData.Read(localIndex); PlayerRegistry::AddLocalPlayer(netId, localIndex); } else { RakNetGUID guid; receivedData.Read(guid); PlayerRegistry::AddRemotePlayer(netId, guid); } } } else if (type == MTID_REMOVEPLAYER) { PlayerID netId; receivedData.Read(netId); PlayerRegistry::RemovePlayer(netId); } }
void ProviderRs232::readyRead() { emit receivedData(_rs232Port.readAll()); //Debug(_log, "received data"); }