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


C++ readMessage函数代码示例

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


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

示例1: main

int main(int argc, char** argv) {
  qRegisterMetaType<std::shared_ptr<CANConnection::Message> >();
  qRegisterMetaType<std::string>();
  QApplication application(argc, argv);
  CANConnection device;
  CANScanCom canCom(device);
  MainWindow mainWindow;
  mainWindow.setWindowTitle("Toyota PRIUS CAN Scan");
  ScannedMessagesTab scannedMessagesTab;
  mainWindow.addControl("Scanned Messages", scannedMessagesTab);
  QObject::connect(&canCom,
    SIGNAL(comException(const std::string&)),
    &mainWindow,
    SLOT(comException(const std::string&)));
  QObject::connect(&canCom,
    SIGNAL(readMessage(std::shared_ptr<CANConnection::Message>)),
    &scannedMessagesTab,
    SLOT(readMessage(std::shared_ptr<CANConnection::Message>)));
  mainWindow.show();
  const int ret = application.exec();
  QObject::disconnect(&canCom,
    SIGNAL(comException(const std::string&)),
    &mainWindow,
    SLOT(comException(const std::string&)));
  QObject::disconnect(&canCom,
    SIGNAL(readMessage(std::shared_ptr<CANConnection::Message>)),
    &scannedMessagesTab,
    SLOT(readMessage(std::shared_ptr<CANConnection::Message>)));
  return ret;
}
开发者ID:jmaye,项目名称:libcan-prius,代码行数:30,代码来源:scan.cpp

示例2: buff

void Client::writeToSocket(std::string const &buffer)
{
  int len = buffer.size();
  int len2;

  len2 = 0;
  if (_step == GAME_STEP)
    ++_nbCmd;
  std::string buff(buffer);

  if (!buff.empty() && buffer[buff.length() - 1] == '\n')
    buff.erase(buff.length() - 1);

  std::cout << "\033[1;34m[CLIENT] Sending message : " << buff << "\033[0m"
	    << std::endl;

  while (len2 < len)
    {
      if ((len2 += write(_socket, buffer.c_str() + len2, len)) == -1)
	throw NException("Error : write failed");
    }
  if (_step == GAME_STEP)
    {
      refreshTime();
      getAns();
      if (_messages.size() == 0 && _regroupMessage.size() > 3
	  && _reading == false)
	{
	  _reading = true;
	  readMessage(_regroupMessage);
	  _reading = false;
	  _regroupMessage.clear();
	}
      if (_messages.size() > 0 && _reading == false)
	{
	  std::cout << "READING" << std::endl;
	  _reading = true;
	  for (size_t i = 0; i < _messages.size() ; ++i)
	    readMessage(_messages[i]);
	  _messages.clear();
	  if (_regroupMessage.size() > 3)
	    readMessage(_regroupMessage);
	  _regroupMessage.clear();
	  std::cout << "CLEAR" << std::endl;
	  _reading = false;
	  std::cout << "STOP READING" << std::endl;
	  std::cout << "TIME: " << _time << std::endl;
	}
    }
}
开发者ID:jonquach,项目名称:zappy,代码行数:50,代码来源:Client.cpp

示例3: malloc

void *atenderPeticion (void *arguments)
{
    strarg *threadArguments = (strarg*)arguments;
    char *httpMessage = malloc(8092);
    char logMessage[BUFFER_SIZE];
    int salida = 0;
    
    do
    {
        salida = readMessage(threadArguments->socketDescriptor, httpMessage);
        if(salida == -1)
        {
            sprintf(logMessage, "ERROR: Cliente %d desconectado abruptamente. Cerrando thread\n", threadArguments->socketDescriptor);;;
        }
        else if (salida == 0)
        {
            sprintf(logMessage, "Cliente %d desconectado de forma normal.\n", threadArguments->socketDescriptor);
        }
        logger(logMessage);
        processHttpMessage(httpMessage, threadArguments->socketDescriptor);
    }
    while(salida > 0);  //TODO El corte debería ser el error de read_message, por ejemplo que se desconecto el cliente es un 0...
    //FD_CLR(argumentosDelThread->socketDescriptor, &readset);
    return NULL;
}
开发者ID:andrescabrera,项目名称:TPprogramacionEnRedes,代码行数:25,代码来源:threads.c

示例4: sendMessage

char sendMessage(char devAddress, char address, char* data, char length, char rw)
{
    char rData = 0;
    I2CIdle();
    I2C2CONbits.SEN = 1;  //Send Start condition
    I2CIdle();

    //SET Slave Address & write (Address shifted one bit left and then the write(0) bit is added)
    I2C2TRN = devAddress << 1; //If reading, the read process is specified after the dummy bytes.

    if (rw == READ) //If in reading mode
    {
        rData = readMessage(devAddress, address);
    }
    else //Otherwise go into writing mode
    {
       writeMessage(address,data, length);
    }

    I2CIdle();
    I2C2CONbits.PEN = 1; //Send Stop condition

    I2CIdle();

    return rData;

}
开发者ID:swalford,项目名称:PICpilot,代码行数:27,代码来源:I2C.c

示例5: processHttpMessage

void processHttpMessage(char *httpMessage, int sockClient)
{
    printf("funcion processHttpMessage\n");
    printf("Full HTTP Message:\n");
    logger(httpMessage);
    char GET[4] = "GET\0";
    char *method = substring(httpMessage, 0, 3);
    logger("Method: ");
    logger(method);
    
    if(strcmp(method, GET) == 0) {
        
        int i = 0;
        while(httpMessage[i] != '\n')
        {
            i++;
        }

        char *path = substring(httpMessage, 5, i - 10);
        logger(path);
        int sockIndexProcess = sendPathToIndexProcess(path);
        char *realPath = malloc(8092);
        readMessage(sockIndexProcess, realPath);
        sendFile(sockClient, realPath);
    }
}
开发者ID:andrescabrera,项目名称:TPprogramacionEnRedes,代码行数:26,代码来源:threads.c

示例6: threadFunction

 void threadFunction(void)
 {
     bool iterate = true;
     for(;iterate;)
     {
         int sensorValue = 0;
         int16_t size = 0;
         size = readMessage(reinterpret_cast<uint8_t*>(&sensorValue), sizeof(sensorValue), 1000);
         std::stringstream ss;
         if(0 > size)
         {
             ss << name() << " : data timeout" << std::endl;
             iterate = false;
         }
         else
         {
             if(sizeof(int) == size)
             {
                 ss << name() << " : received " <<  sensorValue << std::endl;
             }
             else
             {
                 ss << name() << " : received strange message!" << std::endl;
             }
         }
         CLogger() << ss.str();
     }
 }
开发者ID:andriy-bilynskyy,项目名称:OSAL,代码行数:28,代码来源:main.cpp

示例7: while

bool SharedVisualizationClient::receiveServerUpdate(Comm::NetPipe& pipe)
	{
	/* Ignore a list of global server messages: */
	MessageIdType message;
	while((message=readMessage(pipe))!=UPDATE_END)
		switch(message)
			{
			case CREATE_ELEMENT:
				{
				/* Skip an element creation message: */
				unsigned int elementId=pipe.read<Card>();
				std::string algorithmName=read<std::string>(pipe);
				size_t parametersSize=pipe.read<Card>();
				Byte* parameters=new Byte[parametersSize];
				pipe.read(parameters,parametersSize);
				pipe.read<Byte>(); // bool enabled=pipe.read<unsigned char>()!=0;
				
				#ifdef VERBOSE
				std::cout<<"Ignored creation of "<<algorithmName<<" element with ID "<<elementId<<std::endl;
				#endif
				}
			}
	
	return false;
	}
开发者ID:jrevote,项目名称:3DA-3DVisualizer,代码行数:25,代码来源:SharedVisualizationClient.cpp

示例8: connect

void Server::incomingConnection ( int socketDescriptor )
{
    if(this->clientSocketList.size() >= playerSum)
        return;
    ClientSocket* newSocket=new ClientSocket;
    newSocket->setSocketDescriptor(socketDescriptor);

    clientSocketList.append(newSocket);
    ready.append(false);
    this->socketDescriptorList.append(socketDescriptor);
    newSocket->id=clientSocketList.count()-1;
    connect(newSocket,SIGNAL(disconnected()),newSocket,SLOT(onDisconnected()));
    connect(newSocket,SIGNAL(disconnectedSIN(ClientSocket*)),this,SLOT(onDisconnectedSIG(ClientSocket*)));
    connect(newSocket,SIGNAL(disconnected()),newSocket,SLOT(deleteLater()));
    connect(newSocket,SIGNAL(readyRead()),newSocket,SLOT(readMessage()));
    connect(newSocket,SIGNAL(getMessage(int,QString)),this,SLOT(decoder(int,QString)));

    QString temp = "1;";
    int howMany=clientSocketList.size();
    temp += QString::number(this->clientSocketList.size()-1);
    temp += ";";
    this->sendMessage(this->clientSocketList.size()-1,temp);

    if(howMany == playerSum)
        emit this->seatArrangeSIG();
    else
        sendMessage(-1,tr("现有")+QString::number(howMany)+tr("名玩家进入房间,请耐心等候"));
}
开发者ID:dreamStar,项目名称:Asteriated_Grail,代码行数:28,代码来源:Server.cpp

示例9: connect

Client::Client()
{
    connect(this,SIGNAL(readyRead()),this,SLOT(readMessage()));
    connect(logic,SIGNAL(gameStart()),this,SIGNAL(readyToStart()));
    connect(logic,SIGNAL(sendCommand(QString)),this,SLOT(sendMessage(QString)));
    connect(this,SIGNAL(getMessage(QString)),logic,SLOT(getCommand(QString)));
    logic->setClient(this);
}
开发者ID:sheep123,项目名称:Asteriated_Grail,代码行数:8,代码来源:Client.cpp

示例10: QUdpSocket

void handler_client::doListen(quint16 client_port) {
    socket = new QUdpSocket(this);
    connect(socket, SIGNAL(readyRead()), this, SLOT(readMessage()));

    qDebug() << "binding...";

    socket->bind(QHostAddress::Any, client_port);
}
开发者ID:feryandi,项目名称:WeReWolf,代码行数:8,代码来源:handler_client.cpp

示例11: m_device

IncomingMessageParser::IncomingMessageParser(QIODevice *device) :
    m_device(device),
    m_in_progress_msg(NULL)
{
    bool success;
    success = connect(m_device, SIGNAL(readyRead()), this, SLOT(readMessage()), Qt::QueuedConnection);
    Q_ASSERT(success);
}
开发者ID:Innefektiv,项目名称:mineflayer,代码行数:8,代码来源:IncomingMessageParser.cpp

示例12: receiveMessage

static int receiveMessage(int sock, char **msg) {
	int ret = readMessage(sock, (void *)msg);

	//logMessage(*msg, SERVER);
	mqueue_enqueue(dispEvents, *msg, ret * sizeof(char));

	return ret;
}
开发者ID:jsvana,项目名称:project-yet-unnamed,代码行数:8,代码来源:client_main.c

示例13: switch

//------------------------------------------------------------------------------
void SpeakAnnounce::incomingEvent(HANDLE user, HANDLE event)
{
	if (m_event_info.isValidEvent(event))
	{
		bool speak = false;
		switch (m_event_info.getLastEvent())
		{
		  case EVENTTYPE_MESSAGE:
			speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Message);
			break;

		  case EVENTTYPE_URL:
			speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Url);
			break;

		  case EVENTTYPE_ADDED:
			speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Added);
			break;

		  case EVENTTYPE_AUTHREQUEST:
			speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_AuthRequest);
			break;

		  case EVENTTYPE_FILE:
			speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_File);
			break;

		}

		if (!speak)
		{
			return;
		}
		std::wstring event_str = L"";

		if (EVENTTYPE_MESSAGE == m_event_info.getLastEvent())
		{
			if (!readMessage(user))
			{
				return; // message dialog is open so just leave without saying anything
			}
			if ((m_db.getEventFlag(AnnounceDatabase::EventFlag_ReadMsgLength)) && (m_event_info.getMessageSize() <= m_db.getMaxMsgSize()))
			{
				event_str = m_event_info.getMessage(); // conditions met to read the message
			}
			else
			{
				event_str = m_event_info.eventString();
			}
		}
		else
		{
			event_str = m_event_info.eventString();
		}
		m_user_info.insertName(event_str, user); // translate the string, insert the name, then speak it
		message(event_str, user);
	}
}
开发者ID:MrtsComputers,项目名称:miranda-ng,代码行数:59,代码来源:SpeakAnnounce.cpp

示例14: qDebug

void FreeBracketClient::connectToServer(QString host, quint16 port) {
    qDebug() << "Connecting to server...";
    tcpSocket = new QTcpSocket(this);
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
    connect(tcpSocket, SIGNAL(connected()), this, SLOT(connected()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    tcpSocket->abort();
    tcpSocket->connectToHost(QHostAddress(host), port);
}
开发者ID:jkalweit,项目名称:free-bracket,代码行数:9,代码来源:FreeBracketClient.cpp

示例15: QObject

AMCPDevice::AMCPDevice(QObject* parent)
    : QObject(parent), command(AMCPDevice::NONE), state(AMCPDevice::ExpectingHeader), connected(false)
{
    this->socket = new QTcpSocket(this);

    QObject::connect(this->socket, SIGNAL(readyRead()), this, SLOT(readMessage()));
    QObject::connect(this->socket, SIGNAL(connected()), this, SLOT(setConnected()));
    QObject::connect(this->socket, SIGNAL(disconnected()), this, SLOT(setDisconnected()));
}
开发者ID:Mistobaan,项目名称:CasparCG,代码行数:9,代码来源:AMCPDevice.cpp


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