예제 #1
0
void dlgIRC::sendMsg()
{
    QString txt = lineEdit->text();
    lineEdit->clear();
    if( txt.startsWith("/nick ") )
    {
        txt.replace("/nick ", "" );
        session->setNickName( txt );
        mNick = txt;
        session->sendCommand( IrcCommand::createNames( "#mudlet" ) );
        return;
    }
    if( txt.startsWith( "/msg ") )
    {
        if( txt.size() < 5 ) return;
        txt = txt.mid(5);
        int _i = txt.indexOf(" ");
        if( _i == -1 || _i < 1 || txt.size()<_i+2 ) return;
        QString r = txt.mid(0, _i);
        QString m = txt.mid( _i+1 );
        IrcCommand *cmd = IrcCommand::createMessage( r, m );
        session->sendCommand( cmd );
        IrcMessage* msg = IrcMessage::fromCommand( session->nickName(), cmd, session );
        onMessageReceived( msg );
        qDebug()<<"r="<<r<<" msg="<<m;
        session->sendCommand( IrcCommand::createNames( "#mudlet" ) );
        return;
    }

    IrcCommand *cmd = IrcCommand::createMessage( "#mudlet", txt );
    session->sendCommand( cmd );
    IrcMessage* msg = IrcMessage::fromCommand( session->nickName(), cmd, session );
    onMessageReceived( msg );
    session->sendCommand( IrcCommand::createNames( "#mudlet" ) );
}
예제 #2
0
bool CNetDelegate::runRead()
{
	int nRet = m_oSocket.ccRead(m_pReadBuffer, SOCKET_READ_BUFFER_SIZE);
	if( nRet == eSocketIoError || nRet == eSocketIoClosed )
	{
		unregisterScheduler();
		m_oSocket.ccClose();
		m_eStatus = eSocketIoClosed;
		onDisconnected();
		return true;
	}
	else
	{
#if 1
		CCLOG("CCSOCKET READ %d", nRet);
#endif
		m_oReadBuffer.writeData(m_pReadBuffer, (unsigned int)nRet);
#if USING_PACKAGE_HEAD_LENGTH
		while( m_oReadBuffer.isReadable(sizeof(int)) )
		{
			m_oReadBuffer.moveReaderIndexToFront();
			int n_head_len = m_oReadBuffer.readInt();
			if( n_head_len <= 0 )
			{
				CCLOGERROR("invalidate head length");
				m_oReadBuffer.moveLeft(sizeof(int));
			}

			int n_content_len = (int)m_oReadBuffer.length();
			if( n_content_len - (int)(sizeof(int)) >= n_head_len )
			{
				m_oReadBuffer.moveLeft(sizeof(unsigned int));
				CBuffer* pData = m_oReadBuffer.readData(n_head_len);
				m_oReadBuffer.moveLeft(n_head_len);
				m_oReadBuffer.moveReaderIndexToFront();
				m_oReadBuffer.moveWriterIndexToBack();

				onMessageReceived(*pData);
#if USING_LUA
				executeOnMessageReceivedScriptHandler(pData);
#endif
			}else{
				break;
			}
		}
#else
		CBuffer* pData = (CBuffer*) m_oReadBuffer.copy();
		pData->autorelease();
		m_oReadBuffer.clear();
		
		onMessageReceived(*pData);
#if USING_LUA
		executeOnMessageReceivedScripHandler(pData);
#endif

#endif
	}
	return false;
}
예제 #3
0
void ServerStanzaChannel::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>& session) {
	SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Stanza>(element);
	if (!stanza) {
		return;
	}

	stanza->setFrom(session->getRemoteJID());

	if (!stanza->getFrom().isValid())
		return;
	

	SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Message>(stanza);
	if (message) {
		onMessageReceived(message);
		return;
	}

	SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Presence>(stanza);
	if (presence) {
		onPresenceReceived(presence);
		return;
	}

	SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<IQ>(stanza);
	if (iq) {
		onIQReceived(iq);
		return;
	}
}
 ssize_t CMessageBrokerController::Recv(std::string& data)
 {
    DBG_MSG(("CMessageBrokerController::Recv()\n"));
    ssize_t recv = TcpClient::Recv(data);
    DBG_MSG(("Received message: %s\n", data.c_str()));
    m_receivingBuffer += data;
    while (!stop)
    {
       Json::Value root;
       if (!m_reader.parse(m_receivingBuffer, root))
       {
          DBG_MSG(("Received not JSON string! %s\n", m_receivingBuffer.c_str()));
          return recv;
       }
       std::string wmes = m_receiverWriter.write(root);
       DBG_MSG(("Parsed JSON string:%s; length: %d\n", wmes.c_str(), wmes.length()));
       DBG_MSG(("Buffer is:%s\n", m_receivingBuffer.c_str()));
       ssize_t beginpos = m_receivingBuffer.find(wmes);
       if (-1 != beginpos)
       {
          m_receivingBuffer.erase(0, beginpos + wmes.length());
          DBG_MSG(("Buffer after cut is:%s\n", m_receivingBuffer.c_str()));
       } else
       {
          m_receivingBuffer.clear();
       }
       onMessageReceived(root);
    }
    return recv;
 }
예제 #5
0
ChannelWatcher::ChannelWatcher(const Tp::TextChannelPtr &channel, const QString &accountObjectPath, QObject *parent)
    : QObject(parent),
      m_channel(channel),
      m_accountObjectPath(accountObjectPath),
      m_db(QSqlDatabase::database()),
      m_contactDbId(0), //sqlite auto-increment starts at 1
      m_accountDbId(0)
{
    qDebug() << "Delivery reports support" << channel->deliveryReportingSupport();

    connect(channel.data(), &Tp::TextChannel::invalidated, this, &ChannelWatcher::invalidated);
    connect(channel.data(), &Tp::TextChannel::invalidated, this, [=]() {
        qDebug() << "Channel invalidated";
    });

    connect(channel.data(), &Tp::TextChannel::messageReceived, this, &ChannelWatcher::onMessageReceived);
    connect(channel.data(), &Tp::TextChannel::messageSent, this, &ChannelWatcher::onMessageSent);

    qDebug() << this << "New channel being watched" << channel.data();

    storeContactInfo();
    storeAccountInfo();

    Q_FOREACH (const Tp::ReceivedMessage &message, channel->messageQueue()) {
        onMessageReceived(message);
    }
}
예제 #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    winnerB = 0;
    ui->setupUi(this);
    ta = new TaskAllocator();
    socket = new QUdpSocket(this);
    socket->bind(QHostAddress::LocalHost, port1, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
    qDebug() << "socket created";
    connect(socket, SIGNAL(readyRead()), this, SLOT(onMessageReceived()));
    connect(ta, SIGNAL(winnerFound(int,int)),this,SLOT(onWinnerFound(int,int)));
    connect(ta, SIGNAL(taskAssigned(QString)),this,SLOT(onTaskAssigned(QString)));
    connect(ta, SIGNAL(tasksComplete()),this,SLOT(missionComplete()));
    for(int i = 0; i < 3; i++){
        manual[i] = false;
        stopped[i] = false;
    }
    //Make the text area non-editable so we can read key events
    ui->textEdit->setReadOnly(true);

    //Initialize key press trackers to false
    aPressed = wPressed = sPressed = dPressed = false;

//    connect(&socket,SIGNAL(readyRead()),this,SLOT(on_message_received1()));
//    connect(&socket2,SIGNAL(readyRead()),this,SLOT(on_message_received2()));
//    connect(&socket3,SIGNAL(readyRead()),this,SLOT(on_message_received3()));
//    socket.connectToHost("localhost",port1,QIODevice::ReadWrite);
//    socket2.connectToHost("localhost",port2,QIODevice::ReadWrite);
//    socket3.connectToHost("localhost",port3,QIODevice::ReadWrite);
//    socket4.connectToHost("localhost",port4,QIODevice::ReadWrite);
//    r1.socket = &socket;
//    r2.socket = &socket2;
//    r3.socket = &socket3;
//    qDebug() << "attempting connection";
//    if(socket.waitForConnected()&& socket2.waitForConnected()&& socket3.waitForConnected()&& socket4.waitForConnected()){
//        qDebug() << "connected";
//    }else{
//        qDebug() << "not connected";
//    }
    QStringList hHeader;
    hHeader.append("ID");
    hHeader.append("TYPE");
    hHeader.append("STATUS");
    //model.index(1,1,model.index(0,0));
    model = new QStandardItemModel(0,3,this);
    model->setHorizontalHeaderLabels(hHeader);
    ui->robotTable->setModel(model);
    ui->robotTable->setColumnWidth(0,30);
    ui->robotTable->setColumnWidth(1,50);
    ui->robotTable->horizontalHeader()->setStretchLastSection(true);
    connect(&timer, SIGNAL(timeout()), this, SLOT(updateTimer()));
    timer.start(10);
    mStart = false;
    //ui->robotTable->resizeColumnsToContents();
}
Horus::Commons::Network::StreamServerEchoConnection::StreamServerEchoConnection
(
    boost::asio::io_service &io_service,
    const boost::shared_ptr<StreamServerConnectionManager> &manager
) : StreamServerConnection(io_service, manager)
{
    connect(
        this, SIGNAL(messageReceived(QString)),
        this, SLOT(onMessageReceived(QString)));
}
void CdoSampleAppWindow::setupBindings()
{
    QObject::connect(ui->playTestSndBtn, SIGNAL(clicked()),
                     &_appController,  SLOT(playTestSndClicked()));
    QObject::connect(ui->disconnectBtn, SIGNAL(clicked()),
                     &_appController,  SLOT(disconnectBtnClicked()));

    QObject::connect(ui->camCombo, SIGNAL(currentIndexChanged(int)),
                     this, SLOT(onVideoDeviceSelected(int)));
    QObject::connect(ui->micCombo, SIGNAL(currentIndexChanged(int)),
                     this, SLOT(onMicSelected(int)));
    QObject::connect(ui->spkCombo, SIGNAL(currentIndexChanged(int)),
                     this, SLOT(onSpeakerSelected(int)));

    QObject::connect(&_appController, SIGNAL(cdoReady(void*, QString)),
                     this, SLOT(onADLPlatformReady(void*, QString)));

    QObject::connect(&_appController,
                     SIGNAL(mediaDevicesListChanged(int, QVariantMap)),
                     this, SLOT(onMediaDevicesListChanged(int, QVariantMap)));

    QObject::connect(&_appController, SIGNAL(connected()),
                     this, SLOT(onConnected()));
    QObject::connect(&_appController, SIGNAL(disconnected()),
                     this, SLOT(onDisconnected()));

    QObject::connect(&_appController, SIGNAL(localVideoSinkChanged(QString)),
                     this, SLOT(onLocalPreviewSinkChanged(QString)));
    QObject::connect(&_appController, SIGNAL(remoteVideoSinkChanged(QString)),
                     this, SLOT(onRemotePreviewSinkChanged(QString)));
    QObject::connect(&_appController, SIGNAL(remoteScreenSinkChanged(QString)),
                     this, SLOT(onRemoteScreenSinkChanged(QString)));

    QObject::connect(ui->connectBtn, SIGNAL(clicked()),
                     this, SLOT(onConnectClicked()));

    QObject::connect(ui->publishAudioChck, SIGNAL(clicked(bool)),
                     &_appController, SLOT(audioPublishStateChanged(bool)));
    QObject::connect(ui->publishVideoChck, SIGNAL(clicked(bool)),
                     &_appController, SLOT(videoPublishStateChanged(bool)));
    QObject::connect(ui->publishScreenChck, SIGNAL(clicked(bool)),
                     this, SLOT(onScreenPublishStateChanged(bool)));

    QObject::connect(ui->sendMessageBtn, SIGNAL(clicked()),
                     &_appController, SLOT(sendMessageClicked()));
    QObject::connect(&_appController, SIGNAL(messageReceived(QString)),
                     this, SLOT(onMessageReceived(QString)));
}
예제 #9
0
DeclarativeView::DeclarativeView(QWidget *parent)
    : QDeclarativeView(parent), d(new DeclarativeViewPrivate)
{
    TRACE
    d->app = qobject_cast<QtSingleApplication*>(QApplication::instance());

    this->setAttribute(Qt::WA_OpaquePaintEvent);
    this->setAttribute(Qt::WA_NoSystemBackground);
    this->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
    this->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    this->setResizeMode(QDeclarativeView::SizeRootObjectToView);

    this->rootContext()->setContextProperty("__window", this);

    QObject::connect(this->engine(), SIGNAL(quit()), SLOT(close()));
    QObject::connect(d->app, SIGNAL(messageReceived(QString)), SLOT(onMessageReceived(QString)));
}
void ComponentSessionStanzaChannel::handleStanza(boost::shared_ptr<Stanza> stanza) {
	boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(stanza);
	if (message) {
		onMessageReceived(message);
		return;
	}

	boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(stanza);
	if (presence) {
		onPresenceReceived(presence);
		return;
	}

	boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza);
	if (iq) {
		onIQReceived(iq);
		return;
	}
}
예제 #11
0
int Session::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = IrcSession::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: outputString((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 1: newNamesList((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QStringList(*)>(_a[2]))); break;
        case 2: newChannelList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 3: onConnected(); break;
        case 4: onMessageReceived((*reinterpret_cast< IrcMessage*(*)>(_a[1]))); break;
        case 5: onInputReceived((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: onRefreshNames((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 7: onUpdateConnection((*reinterpret_cast< Connection*(*)>(_a[1]))); break;
        case 8: onPassword((*reinterpret_cast< QString*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 9;
    }
    return _id;
}
void OtrProxyChannel::Adaptee::onKeyGenerationFinished(const QString &accountId, bool error)
{
    if(accountId != otrSes.context().accountId) {
        return;
    }
    qCDebug(KTP_PROXY) << "Finished key generation for: " << accountId;
    isGenerating = false;

    if(error) {
        qCWarning(KTP_PROXY) << "Could not generate private key for " << accountId;
        return;
    }
    if(!enqueuedMessages.isEmpty()) {
        for(auto &&mes: enqueuedMessages) {
            onMessageReceived(mes);
        }
        enqueuedMessages.clear();
    } else if(aboutToInit) {
        sendOTRmessage(otrSes.startSession());
    }

    aboutToInit = false;
}
void OtrProxyChannel::Adaptee::connectProxy(
        const Tp::Service::ChannelProxyInterfaceOTRAdaptor::ConnectProxyContextPtr &context)
{
    qCDebug(KTP_PROXY) << "Connecting proxy: " << pc->objectPath();

    connect(chan.data(),
            SIGNAL(messageReceived(const Tp::ReceivedMessage&)),
            SLOT(onMessageReceived(const Tp::ReceivedMessage&)));

    connect(chan.data(),
            SIGNAL(pendingMessageRemoved(const Tp::ReceivedMessage&)),
            SLOT(onPendingMessageRemoved(const Tp::ReceivedMessage&)));

    connect(ps, SIGNAL(keyGenerationStarted(const QString&)), SLOT(onKeyGenerationStarted(const QString&)));
    connect(ps, SIGNAL(keyGenerationFinished(const QString&, bool)), SLOT(onKeyGenerationFinished(const QString&, bool)));

    for(const Tp::ReceivedMessage &m: chan->messageQueue()) {
        onMessageReceived(m);
    }

    isConnected = true;
    context->setFinished();
}
예제 #14
0
BabelWindow::BabelWindow(Client *client, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::BabelWindow)
{
    _client = client;
    ui->setupUi(this);
    connect(_client, SIGNAL(messageReceived()), SLOT(onMessageReceived()));
	
	addNewContact("Galdan");
    addNewContact("Khaled");

	ui->_messagesList->clear();
	_mapMessages.insert("Khaled", new MessagesList());
	MessagesList *list = _mapMessages.value("Khaled");
	*list << "Salut";

	*list << "Ca va ?";

	_mapMessages.insert("Galdan", new MessagesList());
	list = _mapMessages.value("Galdan");
	*list << "Wesh";
	*list << "Trkl ?";
}
예제 #15
0
void CoreClient::handleMessageReceived(Message::ref message) {
	onMessageReceived(message);
}
예제 #16
0
bool CCNetDelegate::runReadByte()
{
    int nRet = m_oSocket.ccRead(m_pReadBuffer + m_wRecvSize, sizeof(m_pReadBuffer) - m_wRecvSize);
    if( nRet == eSocketIoError || nRet == eSocketIoClosed )
    {
        unregisterScheduler();
        m_oSocket.ccClose();
        m_eStatus = eSocketIoClosed;
        onDisconnected();
        return true;
    }
    else
    {
#if 1
        CCLOG("CCSOCKET READ %d", nRet);
#endif
        m_wRecvSize += nRet;
        BYTE cbDataBuffer[SOCKET_BUFFER+sizeof(CMD_Head)];
        WORD wPacketSize = 0;
        CMD_Head * pHead = (CMD_Head *)m_pReadBuffer;
        while( m_wRecvSize >= sizeof(CMD_Head) )
        {
            //效验参数
            wPacketSize = pHead->CmdInfo.wPacketSize;
            //            ASSERT(pHead->CmdInfo.cbVersion == SOCKET_VER);
            //            ASSERT(wPacketSize <= (SOCKET_BUFFER + sizeof(CMD_Head)));
            if (pHead->CmdInfo.cbVersion != SOCKET_VER) throw std::string("数据包版本错误");
            if (wPacketSize > (SOCKET_BUFFER + sizeof(CMD_Head))) throw std::string("数据包太大");
            if (m_wRecvSize < wPacketSize) return 1;
            
            //拷贝数据
            m_dwRecvPacketCount++;
            
            memcpy(cbDataBuffer, m_pReadBuffer, wPacketSize);
            m_wRecvSize -= wPacketSize;
            memcpy(m_pReadBuffer, m_pReadBuffer + wPacketSize, m_wRecvSize);
            
            //解密数据
            WORD wRealySize=CrevasseBuffer(cbDataBuffer,wPacketSize);
            
            //解释数据
            WORD wDataSize = wRealySize - sizeof(CMD_Head);
            void * pDataBuffer = cbDataBuffer + sizeof(CMD_Head);
            CMD_Command Command = ((CMD_Head *)cbDataBuffer)->CommandInfo;
            
            //内核命令
            if (Command.wMainCmdID == MDM_KN_COMMAND)
            {
                switch (Command.wSubCmdID)
                {
                    case SUB_KN_DETECT_SOCKET:	//网络检测
                    {
                        //发送数据
                        sendPacket(MDM_KN_COMMAND, SUB_KN_DETECT_SOCKET, pDataBuffer, wDataSize);
                        break;
                    }
                }
                continue;
            }
            
            //处理数据
            //            bool bSuccess = m_pITCPSocketSink->OnEventTCPSocketRead(GetSocketID(), Command, pDataBuffer, wDataSize);
            //            if (bSuccess == false) throw std::string("网络数据包处理失败");
            
            onMessageReceived((const char *)cbDataBuffer, wRealySize);
        }
    }
    return false;
}
예제 #17
0
void SlackRTM::handlePayloadReceived(const std::string &payload) {
	Json::Value d;
	Json::CharReaderBuilder rbuilder;
	std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
	if (!reader->parse(payload.c_str(), payload.c_str() + payload.size(), &d, nullptr)) {
		LOG4CXX_ERROR(logger, "Error while parsing JSON");
		LOG4CXX_ERROR(logger, payload);
		return;
	}

	STORE_STRING(d, type);

	if (type == "message") {
		STORE_STRING(d, channel);
		STORE_STRING(d, text);
		STORE_STRING(d, ts);
		STORE_STRING_OPTIONAL(d, subtype);
		STORE_STRING_OPTIONAL(d, purpose);

		Json::Value &attachments = d["attachments"];
		if (attachments.isArray()) {
			for (unsigned i = 0; i < attachments.size(); i++) {
				STORE_STRING_OPTIONAL(attachments[i], fallback);
				if (!fallback.empty()) {
					text += fallback;
				}
			}
		}

		if (subtype == "bot_message") {
			STORE_STRING(d, bot_id);
			onMessageReceived(channel, bot_id, text, ts);
		}
		else if (subtype == "me_message") {
			text = "/me " + text;
			STORE_STRING(d, user);
			onMessageReceived(channel, user, text, ts);
		}
		else if (subtype == "channel_join") {
			
		}
		else if (!purpose.empty()) {
			
		}
		else {
			STORE_STRING(d, user);
			onMessageReceived(channel, user, text, ts);
		}
	}
	else if (type == "channel_joined"
		  || type == "channel_created") {
		std::map<std::string, SlackChannelInfo> &channels = m_idManager->getChannels();
		SlackAPI::getSlackChannelInfo(NULL, true, d, payload, channels);
	}
	else if (type == "error") {
		GET_OBJECT(d, error);
		STORE_INT(error, code);

		if (code == 1) {
			LOG4CXX_INFO(logger, "Reconnecting to Slack network");
			m_pingTimer->stop();
			m_client->disconnectServer();
			start();
		}
	}
}
예제 #18
0
void XMPPFrontend::handleMessage(boost::shared_ptr<Swift::Message> message) {
	onMessageReceived(message);
}
예제 #19
0
MessageLogModel::MessageLogModel( QObject* parent )
  : QAbstractListModel( parent )
  , mMessageLog( QgsMessageLog::instance() )
{
  connect( mMessageLog, SIGNAL(messageReceived(QString,QString,QgsMessageLog::MessageLevel)), this, SLOT( onMessageReceived(QString,QString,QgsMessageLog::MessageLevel)));
}
예제 #20
0
void PNetworkServer::update()
{
    if (m_state == NETWORK_CONNECTED)
    {
        pint32 ret;
        while ((ret = enet_host_service(m_data->server, &m_data->event, P_NETWORK_POLL_TIME)) > 0)
        // FIXME: why enet_host_check_events doesn't work as enet_host_service()?
        //while ((ret = enet_host_check_events(m_data->server, &m_data->event)) > 0)
        {
            switch (m_data->event.type)
            {
                case ENET_EVENT_TYPE_CONNECT:
                    {
                        puint32 id = m_nextId++;
                        PNetworkPeer *peer = onPeerConnected(id);
                        if (peer != P_NULL)
                        {
                            m_peers.insert(id, peer);
                            peer->data()->peer = m_data->event.peer;
                        }
                        m_data->event.peer->data = PNEW(puint32);
                        *(puint32*)(m_data->event.peer->data) = id;
                    }
                    break;
                case ENET_EVENT_TYPE_RECEIVE:
                    {
                        puint32 id = *(puint32*)(m_data->event.peer->data);
                        PMap<puint32, PNetworkPeer*>::iterator it = m_peers.find(id);
                        if (it != m_peers.end())
                        {
                            onMessageReceived(it.value(), (const puint8 *)(m_data->event.packet->data), 
                                m_data->event.packet->dataLength);
                        }
                        else
                        {
                            PLOG_ERROR("Failed to find network connection %d.", id);
                        }
                        enet_packet_destroy (m_data->event.packet);
                    }
                    break;
                case ENET_EVENT_TYPE_DISCONNECT:
                    {
                        puint32 id = *(puint32*)(m_data->event.peer->data);
                        PMap<puint32, PNetworkPeer*>::iterator it = m_peers.find(id);
                        if (it != m_peers.end())
                        {
                            onPeerDisconnected(it.value());
                            PDELETE(it.value());
                            m_peers.erase(it);
                            puint32 *tmp = (puint32*)(m_data->event.peer->data);
                            PDELETE(tmp);
                        }
                        else
                        {
                            PLOG_ERROR("Failed to find network connection %d.", id);
                        }
                    }
                    break;
                default:
                    PASSERT_NOTREACHABLE("Unknown server side event.");
                    break;
            }
        }

        if (ret < 0)
        {
            m_state = NETWORK_ERROR;
        }
    }
}
XAirAuxBlock::XAirAuxBlock(MainController* controller, QString uid)
    : OneInputBlock(controller, uid)
    , m_panNode(nullptr)
    , m_onNode(nullptr)
    , m_channelNumber(this, "channelNumber", 1, 1, 32)
    , m_bus(this, "bus", 0, 0, 16)
    , m_faderPos(this, "faderPos", 0.0, 0, 1)
    , m_pan(this, "pan", 0.5)
    , m_boost(this, "boost", true)
    , m_on(this, "on", true)
    , m_pauseValueTransmission(false)
{
    m_heightIsResizable = true;

    m_panNode = createInputNode("panNode");
    m_onNode = createInputNode("onNode");

    m_onNode->enableImpulseDetection();
    connect(m_onNode, &NodeBase::impulseBegin, [this](){ m_on = true; });
    connect(m_onNode, &NodeBase::impulseEnd, [this](){ m_on = false; });

    m_subscribeRefreshTimer.setInterval(10000);  // 10s
    connect(&m_subscribeRefreshTimer, SIGNAL(timeout()), this, SLOT(updateSubscription()));
    m_subscribeRefreshTimer.start();

    connect(&m_faderPos, SIGNAL(valueChanged()), this, SIGNAL(decibelChanged()));

    connect(&m_label, SIGNAL(valueChanged()), this, SLOT(sendName()));
    connect(&m_faderPos, SIGNAL(valueChanged()), this, SLOT(sendFaderPos()));
    connect(&m_pan, SIGNAL(valueChanged()), this, SLOT(sendPan()));
    connect(&m_on, SIGNAL(valueChanged()), this, SLOT(sendOn()));

    connect(&m_channelNumber, SIGNAL(valueChanged()), this, SLOT(retrieveStateFromConsole()));
    connect(&m_bus, SIGNAL(valueChanged()), this, SLOT(retrieveStateFromConsole()));

    connect(m_inputNode, &NodeBase::dataChanged, [this](){ m_faderPos.setValue(m_inputNode->getValue()); });
    connect(m_panNode, &NodeBase::dataChanged, [this](){ m_pan.setValue(m_panNode->getValue()); });

    connect(controller->audioConsole(), SIGNAL(messageReceived(OSCMessage)), this, SLOT(onMessageReceived(OSCMessage)));

}