本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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("名玩家进入房间,请耐心等候"));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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()));
}