当前位置: 首页>>代码示例>>C++>>正文


C++ dataReceived函数代码示例

本文整理汇总了C++中dataReceived函数的典型用法代码示例。如果您正苦于以下问题:C++ dataReceived函数的具体用法?C++ dataReceived怎么用?C++ dataReceived使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dataReceived函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void labPort::read()
{
    if( _closing )
    {
        return;
    }

    if( _minBytesRead == -10 )
    {
        while( _port.canReadLine() )
        {
            emit dataReceived( _port.readLine() );
        }
    }
    else
    {
        while( _port.bytesAvailable() >= _minBytesRead
               && _port.bytesAvailable() > 0 )
        {
            if( _minBytesRead > 0 )
            {
                int bytesRead = _port.read( _buffer, _minBytesRead );
                emit dataReceived( QByteArray( _buffer, bytesRead ) );
            }
            else
            {
                emit dataReceived( _port.readAll() );
            }
        }
    }
}
开发者ID:bchjoerni,项目名称:mlab,代码行数:31,代码来源:labport.cpp

示例2: verify

    void DBClientCursor::requestMore() {
        verify( cursorId && batch.pos == batch.nReturned );

        if (haveLimit) {
            nToReturn -= batch.nReturned;
            verify(nToReturn > 0);
        }
        BufBuilder b;
        b.appendNum(opts);
        b.appendStr(ns);
        b.appendNum(nextBatchSize());
        b.appendNum(cursorId);

        Message toSend;
        toSend.setData(dbGetMore, b.buf(), b.len());
        auto_ptr<Message> response(new Message());

        if ( _client ) {
            _client->call( toSend, *response );
            this->batch.m = response;
            dataReceived();
        }
        else {
            verify( _scopedHost.size() );
            ScopedDbConnection conn(_scopedHost);
            conn->call( toSend , *response );
            _client = conn.get();
            this->batch.m = response;
            dataReceived();
            _client = 0;
            conn.done();
        }
    }
开发者ID:328500920,项目名称:mongo,代码行数:33,代码来源:dbclientcursor.cpp

示例3: assert

void DBClientCursor::requestMore() {
    assert( cursorId && pos == nReturned );

    if (haveLimit) {
        nToReturn -= nReturned;
        assert(nToReturn > 0);
    }
    BufBuilder b;
    b.append(opts);
    b.append(ns.c_str());
    b.append(nextBatchSize());
    b.append(cursorId);

    Message toSend;
    toSend.setData(dbGetMore, b.buf(), b.len());
    auto_ptr<Message> response(new Message());

    if ( connector ) {
        connector->call( toSend, *response );
        m = response;
        dataReceived();
    }
    else {
        assert( _scopedHost.size() );
        ScopedDbConnection conn( _scopedHost );
        conn->call( toSend , *response );
        connector = conn.get();
        m = response;
        dataReceived();
        connector = 0;
        conn.done();
    }
}
开发者ID:erickt,项目名称:mongo,代码行数:33,代码来源:dbclientcursor.cpp

示例4: getNodeSocket

qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16 * port = 0) {
    qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port);

    SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
    if (sendingNode) {
        emit dataReceived(sendingNode->getType(), incomingPacket.size());
    } else {
        emit dataReceived(NodeType::Unassigned, incomingPacket.size());
    }

    return result;
}
开发者ID:Dreckinfeuer,项目名称:hifi,代码行数:12,代码来源:LimitedNodeList.cpp

示例5: medPacsMover

void medPacsDataSource::onPacsMove( const QVector<medMoveCommandItem>& cmdList)
{
    medPacsMover* mover = new medPacsMover(cmdList);
    connect(mover, SIGNAL(import(QString)), this, SIGNAL(dataReceived(QString)));
    medJobManager::instance()->registerJobItem(mover, tr("Moving"));
    QThreadPool::globalInstance()->start(mover);
}
开发者ID:Hakim-F,项目名称:medInria-public,代码行数:7,代码来源:medPacsDataSource.cpp

示例6: dataReceived

void QtNetworkReplyThreadSafeProxy::localForwardData()
{
    if (m_reply->bytesAvailable()) {
        QByteArray data = m_reply->read(m_reply->bytesAvailable());
        emit dataReceived(data);
    }
}
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:7,代码来源:QtNAMThreadSafeProxy.cpp

示例7: while

void YAQSProxy::processPendingDatagrams()
{
    while (udpSocket.hasPendingDatagrams()) {
        QByteArray datagram;
        datagram.resize(udpSocket.pendingDatagramSize());
        udpSocket.readDatagram(datagram.data(), datagram.size());
        QList<QByteArray> LstData = datagram.split('|');

        switch(LstData[0].toInt())
        {
        case ModuleType::IO:
            IO_dperc_WheelPos = LstData[1].toDouble();
            IO_dperc_ThrottlePos = LstData[2].toDouble();
            break;
        case ModuleType::SYSTEMS:
            SYST_kmhSpeed = LstData[1].toDouble();
            SYST_rpmEngine = LstData[2].toDouble();
            SYST_degmn_Latitude = LstData[3].toDouble();
            SYST_degmn_Longitude = LstData[4].toDouble();
            SYST_deg_Heading = LstData[5].toDouble();
            break;
        }

        emit dataReceived();
    }
}
开发者ID:AkimF,项目名称:MeetupMobileQtQml,代码行数:26,代码来源:yaqsproxy.cpp

示例8: PSOCK_BEGIN

// This function is going to use uIP's protosockets to handle the connection.
// This means it must return int, because of the way the protosockets work.
// In a nutshell, when a PSOCK_* macro needs to wait for something, it will
// return from handle_connection so that other work can take place.  When the
// event is triggered, uip_callback() will call this function again and the
// switch() statement (see below) will take care of resuming execution where
// it left off.  It *looks* like this function runs from start to finish, but
// that's just an illusion to make it easier to code :-)
int
UIPClient::handle_connection(uip_tcp_appstate_t *s)
{
  // All protosockets must start with this macro.  Its internal implementation
  // is that of a switch() statement, so all code between PSOCK_BEGIN and
  // PSOCK_END is actually inside a switch block.  (This means for example,
  // that you can't declare variables in the middle of it!)

  struct psock *p = &s->p;
  uip_userdata_t *u = (uip_userdata_t *) s->user;

  PSOCK_BEGIN(p);

    if (uip_newdata() && readyToReceive(s))
      {
        PSOCK_READBUF_LEN(p, 0); //TODO check what happens when there's more new data incoming than space left in UIPClients buffer (most likely this is just discarded, isn't it?)
        dataReceived(s);
      }

    if (readyToSend(s))
      {
        PSOCK_SEND(p, u->out_buffer, u->out_len);
        dataSent(s);
      }

    if (isClosed(s))
      {
        // Disconnect.
        PSOCK_CLOSE(p);
      }

    // All protosockets must end with this macro.  It closes the switch().
  PSOCK_END(p);
}
开发者ID:eduardofigs,项目名称:arduino_uip,代码行数:42,代码来源:UIPClient.cpp

示例9: while

void Server::readyRead()
{
  QTcpSocket* socket = static_cast<QTcpSocket*>(sender());
  QByteArray* buffer = buffers.value(socket);
  qint32* s = sizes.value(socket);
  qint32 size = *s;
  while(socket->bytesAvailable() > 0) {
    buffer->append(socket->readAll());
    while((size == 0 && buffer->size() >= 4) || (size > 0 && buffer->size() >= size))
    {
      if(size == 0 && buffer->size() >= 4)
      {
        size = ArrayToInt(buffer->mid(0, 4));
        *s = size;
        buffer->remove(0, 4);
      }
      if(size > 0 && buffer->size() >= size)
      {
        QByteArray data = buffer->mid(0, size);
        buffer->remove(0, size);
        size = 0;
        *s = size;
        emit dataReceived(socket, data);
      }
    }
  }
}
开发者ID:ghostec,项目名称:White2,代码行数:27,代码来源:Server.cpp

示例10: connect

TcpClientSocket::TcpClientSocket(QObject *parent,int port)
{
    connect(this,SIGNAL(readyRead()),this,SLOT(dataReceived()));
//    connect(this,SIGNAL(sendtoall(QString)),this,SLOT(dataReceived(QString)));
    connect(this,SIGNAL(disconnected()),this,SLOT(slotDisconnected()));
    isfirst=port;
}
开发者ID:xyzyx233,项目名称:QT_TcpServer,代码行数:7,代码来源:tcpclientsocket.cpp

示例11: setClientState

    void
    RTMPSession::streamStatusChanged(StreamStatus_t status)
    {
        if(status & kStreamStatusConnected && m_state < kClientStateConnected) {
            setClientState(kClientStateConnected);
        }
        if(status & kStreamStatusReadBufferHasBytes) {
            dataReceived();
        }
        if(status & kStreamStatusWriteBufferHasSpace) {
            if(m_state < kClientStateHandshakeComplete) {
                handshake();
            } else {
                
#ifdef __APPLE__
                dispatch_semaphore_signal(m_networkWaitSemaphore);
#else 
                m_networkMutex.unlock();
                m_networkCond.notify_one();
#endif
            }
        }
        if(status & kStreamStatusEndStream) {
            setClientState(kClientStateNotConnected);
        }
        if(status & kStreamStatusErrorEncountered) {
            setClientState(kClientStateError);
        }
    }
开发者ID:1072258106,项目名称:LiveVideoCoreSDK,代码行数:29,代码来源:RTMPSession.cpp

示例12: close

void NetworkConnection::continueReceive()
{
	if (closed || sendError)	// Close if anything is wrong
	{
		close();
	}
	else
	{
		bufferInfo.buf = (char*)receiveBuffer;	// Set buffer data
		bufferInfo.len = BUFFER_SIZE;
	
										// 0 means send completed instantly
		if (WSARecv(connection, &bufferInfo, 1, &bytesReceived, 
			&flags, &receiveOverlapped, NULL) == 0) 
		{
			dataReceived();	// Wait for more data
		}
		else
		{
			if (WSAGetLastError() == WSA_IO_PENDING) // Data is pending
			{		// Send a wait handle to the WinAPI thread pool
				RegisterWaitForSingleObject(&newWaitHandle, 
					receiveOverlapped.hEvent, 
					DataReceivedCallback, 
					this, INFINITE, WT_EXECUTEONLYONCE);
			}
			else
			{
				close();
			}
		}
	}
}
开发者ID:martinmine,项目名称:winsockserver,代码行数:33,代码来源:NetworkConnection.cpp

示例13: QTcpSocket

void Widget::on_pushButton_2_clicked()
{
    QString ipAddress = "127.0.0.1";
    int port = 8010;

    if(!status)
    {
        tcpSocket = new QTcpSocket(this);
        connect(tcpSocket, SIGNAL(connected()),
        this, SLOT(tcpConnected()));
        connect(tcpSocket, SIGNAL(disconnected()),
        this, SLOT(tcpDisconnected()));
        connect(tcpSocket, SIGNAL(readyRead()),
        this, SLOT(dataReceived()));
        tcpSocket->connectToHost(ipAddress, port);
        status = true;
    }
    else
    {
        int length = 0;
        QString message = userName + tr(":Leave Chat Room");
        length = tcpSocket->write(message.toLatin1(), message.length());

        if(length != message.length())
        {
            return;
        }

        tcpSocket->disconnectFromHost();
        status = false;
    }
}
开发者ID:Soler-he,项目名称:QtChatClient,代码行数:32,代码来源:widget.cpp

示例14: in

QString ClientThread::waitForName()
{
    // Wait for the connecting client to send its username
    QDataStream in(connection);
    in.setVersion(QDataStream::Qt_4_0);

    QString name;

    connection->waitForReadyRead(5000);

    quint16 blockSize = 0;
    while (connection->bytesAvailable() < (int)sizeof(quint16));

    in >> blockSize;

    while (connection->bytesAvailable() < blockSize);

    quint8 type;
    in >> type;
    in >> name;

    connect(connection, SIGNAL(readyRead()), this, SLOT(dataReceived()));

    username = name;

    qDebug() << name << "connected and sent username";

    return name;
}
开发者ID:rc2524,项目名称:Homework7,代码行数:29,代码来源:clientthread.cpp

示例15: setClientState

 void
 RTMPSession::streamStatusChanged(StreamStatus_t status)
 {
     if(status & kStreamStatusConnected && m_state < kClientStateConnected) {
         setClientState(kClientStateConnected);
     }
     if(status & kStreamStatusReadBufferHasBytes) {
         dataReceived();
     }
     if(status & kStreamStatusWriteBufferHasSpace) {
         if(m_state < kClientStateHandshakeComplete) {
             handshake();
         } else if (!m_ending) {
             m_jobQueue.enqueue([this]() {
                 this->write(nullptr, 0);
             });
         }
     }
     if(status & kStreamStatusEndStream) {
         setClientState(kClientStateNotConnected);
     }
     if(status & kStreamStatusErrorEncountered) {
         setClientState(kClientStateError);
     }
 }
开发者ID:ajumalebrahim,项目名称:VideoCore,代码行数:25,代码来源:RTMPSession.cpp


注:本文中的dataReceived函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。