Example #1
0
serialPort::serialPort(QObject *parent) : QObject(parent)
{
    serial = new QSerialPort(this);
    QSerialPort::connect(serial, SIGNAL(readyRead()), this, SLOT(readyRead()));

    mSerialSetup = new serial_setup();
    connect(mSerialSetup, SIGNAL(connectToPort()),this, SLOT(connectToSocket()));

}
Example #2
0
void QVidiChat::onChannelInfoLoaded()
{
    QNetworkReply * reply = qobject_cast< QNetworkReply * >( sender() );

    QJsonParseError parseError;

    QJsonDocument jsonDoc = QJsonDocument::fromJson( reply->readAll(), &parseError );

    if( QJsonParseError::NoError == parseError.error && jsonDoc.isObject() )
    {
        QJsonObject jsonObj = jsonDoc.object();

        QJsonObject jsonUser = jsonObj[ "user" ].toObject();

        QJsonObject jsonChannel = jsonUser[ "Channel" ].toObject();

        channelId_ = jsonChannel[ "name" ].toString();


        int delPos = channelId_.indexOf( '_' );

        if( delPos > 0 )
        {
            channelId_ = channelId_.right( channelId_.length() - delPos - 1 );
            connectToSocket();
        }
        else
        {
            if( isShowSystemMessages() )
            {
                emit newMessage( ChatMessage( SERVICE_NAME, SERVICE_USER_NAME, tr( "Can not connect to " ) + channelName_ + "...", QString(), this ) );
                emitSystemMessage( SERVICE_NAME, SERVICE_USER_NAME, tr( "Can not connect to " ) + channelName_ + tr( "..." ) );
            }

            startUniqueTimer( reconnectTimerId_, RECONNECT_INTERVAL );
        }


        //        connectToJoinSocket();
        //loadSid();
    }

    reply->deleteLater();
}
Example #3
0
//program
int main(int argc, char **argv)
{
    addrAr = NULL;
    sockfd = 0;
    char buf[BUFLEN];
    connectToSocket(argv[1], argv[2]);
    while(1)
    {
        //for multiple requests maybe
        struct request *requests = (struct request*) malloc(sizeof (struct request) + BUFLEN);  
        int bal = 0;
        bal = recvfrom(sockfd, requests, sizeof buf, 0, &recAddr, &fromlen);
        if(bal > 0) {
            printf("recv()'d %d bytes of data in buf\n", bal);
            readRequestType(requests, bal);       
        }    
    }
    return 0;
}
Example #4
0
void LR_IPC_OUT::timerCallback()
{
    if (!isConnected())
        connectToSocket("127.0.0.1", LR_OUT_PORT, 100);
}