本文整理汇总了C++中receiveMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ receiveMessage函数的具体用法?C++ receiveMessage怎么用?C++ receiveMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了receiveMessage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sim_ReadDigitalU8
uInt8 sim_ReadDigitalU8(uInt32 port)
{
char buff[100];
char lixo[100];
uInt32 value;
sprintf(buff,"%s %02X %02X","ReadDigitalU8", port, 0);
sendMessage(buff);
receiveMessage(buff);
sscanf(buff,"%s %02X %02X",lixo, &port, &value);
return((uInt8) value);
}
开发者ID:dmr-goncalves,项目名称:SI,代码行数:16,代码来源:interface.cpp
示例2: receiveMessage
// Receives a message.
// The message is represented as a list of byte arrays representing
// a message's parts. If the message is not a multi-part message the
// list will only contain one array.
inline QList<QByteArray> receiveMessage()
{
QList<QByteArray> parts;
ZMQMessage msg;
while (receiveMessage(&msg))
{
parts += msg.toByteArray();
msg.rebuild();
if (!hasMoreMessageParts())
break;
}
return parts;
}
开发者ID:dgtBartS,项目名称:nzmqt,代码行数:20,代码来源:nzmqt.hpp
示例3: assert
// Receive notification that the SSL handshake has completed successfully
void Server::handshakeComplete()
{
QSslSocket *socket = dynamic_cast<QSslSocket *>(sender());
assert(socket);
connect(socket, SIGNAL(disconnected()), this, SLOT(connectionClosed()));
connect(socket, SIGNAL(readyRead()), this, SLOT(receiveMessage()));
ui->logTextEdit->append(QString("[%1] Accepted connection from %2:%3")
.arg(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ap"))
.arg(socket->peerAddress().toString())
.arg(socket->peerPort()));
sockets.push_back(socket);
users.push_back(socket->peerPort());
}
开发者ID:andrewly,项目名称:3574_HW7,代码行数:17,代码来源:server.cpp
示例4: QObject
LocalSocketIpcClient::LocalSocketIpcClient(QString remoteServername, QObject *parent) :
QObject(parent)
{
m_socket = new QLocalSocket(this);
m_serverName = remoteServername;
connect(m_socket, SIGNAL(connected()), this, SLOT(socket_connected()));
connect(m_socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected()));
m_socket->connectToServer(m_serverName, QLocalSocket::ReadWrite);
connect(m_socket, SIGNAL(readyRead()), this, SLOT(receiveMessage()));
connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
this, SLOT(socket_error(QLocalSocket::LocalSocketError)));
}
开发者ID:smitp,项目名称:bibref-qt,代码行数:16,代码来源:LocalSocketIpcClient.cpp
示例5: while
NZMQT_INLINE QList<QByteArray> ZMQSocket::receiveMessage(ReceiveFlags flags_)
{
QList<QByteArray> parts;
ZMQMessage msg;
while (receiveMessage(&msg, flags_))
{
parts += msg.toByteArray();
msg.rebuild();
if (!hasMoreMessageParts())
break;
}
return parts;
}
开发者ID:jonesmz,项目名称:nzmqt,代码行数:16,代码来源:impl.hpp
示例6: sendMessage
void sendMessage(uint8_t send_list) {
uint8_t i, tries, channel, send_mask;
// send to only good channels
send_list &= ALL_GOOD_CHANNELS;
for (tries=TX_TRIES; tries>0; tries--) {
handshake_retry_addition = (tries * RETRY_INCREMENT);
//trying to make it do the sendMessage more times on failed channels
send_mask = 0x01;
for (channel=1; channel<=MAX_CHANNELS; channel++) {
uint8_t good_tx = TRUE;
if (send_list & send_mask) {
//putnum_ud(channel);
/*
* Check if the line to transmit on is already being used.
* If so, receive the message and then carry on.
*/
if (pollClockLine(channel) == 0) {
receiveMessage(channel);
}
for (i=0; i<num_bytes_in_tx_msg_buff; i++) {
if (sendByte(tx_msg_buff[i], channel) == FALSE) {
//the message was not received.
//mark this channel not to be cleared from sendList so it can be resent later.
good_tx = FALSE;
break;
}
else
good_tx = TRUE;
}
}
if (good_tx == TRUE) {
send_list &= ~send_mask; //tx was good. clear the bit from sendList to avoid resending
}
send_mask <<= 1; // try sending to the next channel
}
}
// update goodChannels to remove channels that did not succeed
// this works because sendList keeps track of which channels have not received the message yet.
good_channels &= ~send_list;
num_bytes_in_tx_msg_buff = 0;
}
开发者ID:chazmatazz,项目名称:proto-mirror,代码行数:46,代码来源:comm.c
示例7: recebedorDados
void * recebedorDados(void * lixo){
char message[MAXSIZE];
while(true){
receiveMessage(fdSocket,message,sizeof(int));
if((rand()%100)<95 ){
printf("recebeu %s \n",message);
if((rand()%100)<90 ){
sendMessage(fdSocket,message,sizeof(int)); //Envia mensagem
printf("confirmou %s \n",message);
}else{
printf("falha na confirmação\n");
}
}
}
printf("acabou recebedor \n");
}
开发者ID:douglasvaghetti,项目名称:Trabalho-do-pedro,代码行数:17,代码来源:g_back_recebe.cpp
示例8: semTake
/**
* Execute a transaction with a Jaguar that gets some property.
*
* Jaguar always generates a message with the same message ID when replying.
*
* @param messageID The messageID to read from the CAN bus (device number is added internally)
* @param data The up to 8 bytes of data that was received with the message
* @param dataSize Indicates how much data was received
*/
void CANJaguar::getTransaction(UINT32 messageID, UINT8 *data, UINT8 *dataSize)
{
UINT32 targetedMessageID = messageID | m_deviceNumber;
INT32 status = 0;
// Make sure we don't have more than one transaction with the same Jaguar outstanding.
semTake(m_transactionSemaphore, WAIT_FOREVER);
// Send the message requesting data.
status = sendMessage(targetedMessageID, NULL, 0);
wpi_assertCleanStatus(status);
// Wait for the data.
status = receiveMessage(&targetedMessageID, data, dataSize);
wpi_assertCleanStatus(status);
// Transaction complete.
semGive(m_transactionSemaphore);
}
开发者ID:tjradcliffe,项目名称:SimpleRobotEmulator,代码行数:27,代码来源:CANJaguar.cpp
示例9: sendReceive
void Client::listMails() {
std::string message = "LIST\n";
sendReceive(message); // status message
receiveMessage(message); // data
if (message.length() == 3) { // = ".CRLF"
std::cout << "No new messages" << std::endl;
return;
}
if (shortMessage) {
// remove last dot + CRLF
message.erase( message.length() - 3, 3);
}
std::cout << message;
}
开发者ID:aleksandrm8,项目名称:Labs_Nets,代码行数:18,代码来源:client.cpp
示例10: sendMessage
Message::Result Scene::sendMessage(const Message& message)
{
if (message.passFilter(getID()))
{
if ((message.passFilter(Message::Scene) || (this == &Engine::getSharedScene() && message.passFilter(Message::SharedScene))))
{
if (receiveMessage(message) == Message::Result::Escape)
return Message::Result::Escape;
}
}
const unsigned short objectField = Message::Object | Message::Component;
if (message.passFilter(objectField) && Object::sendMessage(message) == Message::Result::Escape)
return Message::Result::Escape;
return Message::Result::Continue;
}
开发者ID:Jopnal,项目名称:Jopnal,代码行数:18,代码来源:Scene.cpp
示例11: QApplication
Application::Application(int &argc, char *argv[])
: QApplication(argc, argv)
, d_ptr(new ApplicationPrivate)
{
Q_D(Application);
d->isRunning = false;
d->sharedMemory.setKey(GUI_APPLICATION_SHARED_MEMORY_KEY);
if (d->sharedMemory.attach()) {
d->isRunning = true;
} else {
if (!d->sharedMemory.create(1))
return;
connect(&d->localServer, SIGNAL(newConnection()), SLOT(receiveMessage()));
d->localServer.listen(GUI_APPLICATION_SHARED_MEMORY_KEY);
}
}
开发者ID:0x414c,项目名称:SpeedCrunch,代码行数:18,代码来源:application.cpp
示例12: receiveMessage
//--------------------------------------------------------------
void ofApp::update(){
if (client.isConnected() && started) {
vector<ofxJSONElement> elements = receiveMessage();
for (int i = 0; i < elements.size(); i++) {
ofxJSONElement element = new ofxJSONElement();
element = elements[i];
//if data frame
for (Json::ArrayIndex i = 0; i < element["DATA"].size(); i++) {
//get element at index i
ofxJSONElement sub = elements[i]["DATA"][i];
//display value type and timestamp
cout << "received " << sub["ID"].asString() << " at " << sub["Timestamp"].asFloat() << " ";
//end line
cout << endl;
//store eeg values
if (sub["ID"].asString() == "eeg_alpha") fitEegData(sub, eegAlpha);
if (sub["ID"].asString() == "eeg_beta") fitEegData(sub, eegBeta);
if (sub["ID"].asString() == "eeg_theta") fitEegData(sub, eegTheta);
//store eda values
if (sub["ID"].asString() == "eda_tonic") fitEdaData(sub, edaFasic);
if (sub["ID"].asString() == "eda_fasic") fitEdaData(sub, edaTonic);
//store ecg values
if (sub["ID"].asString() == "ecg_hr") ecg = sub["Values"][0].asFloat();
}
if (element["STATUS"].asString() == "OK") {
//if request accepted
started = true;
cout << "start request accepted." << endl;
}
else if (element["STATUS"].asString() == "Error") {
//error in the server when receiving the message
ofLogError(element["MSG"].asString());
}
}
}
}
开发者ID:ReallyRad,项目名称:MotorShow,代码行数:45,代码来源:ofApp.cpp
示例13: getprotobyname
Socket::Socket(std::string const &serv, int port)
{
struct protoent *pe;
struct sockaddr_in sockaddr;
socklen_t socksize;
int sock;
int okay;
pe = getprotobyname("TCP");
socksize = sizeof(struct sockaddr);
if ((sock = socket(AF_INET, SOCK_STREAM, pe->p_proto)) == -1)
{
std::cerr << "Socket creation failed." << std::endl;
exit(2);
}
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(port);
sockaddr.sin_addr.s_addr = inet_addr(serv.c_str());
if ((connect(sock, reinterpret_cast<const struct sockaddr *>(&sockaddr), socksize)) != 0)
{
std::cerr << "Socket connection failed." << std::endl;
exit(3);
}
m_sock = sock;
m_fds.fd = m_sock;
m_fds.events = POLLIN;
okay = 0;
if (toRead())
{
okay = 1;
if (receiveMessage() != "BIENVENUE")
okay = 0;
}
if (okay)
{
m_okay = true;
sendMessage("GRAPHIC");
}
else
{
m_okay = false;
std::cerr << "\'BIENVENUE\' not received..." << std::endl << "Exiting ..." << std::endl;
}
}
开发者ID:Kafei59,项目名称:epitech-projects,代码行数:44,代码来源:Socket.cpp
示例14: rbSendMessageHelper
//This does the actual sending of the message
//modifies: nothing
//effects: send message in the Q_tx_msg_buff on the channel
//NOTE: This method does NOT mess with or consider anything having to do with the channelQueuesArray at all
uint8_t rbSendMessageHelper(uint8_t channel, uint8_t message[], uint8_t messageLength) {
if (channel <= 0 || channel > MAX_CHANNELS) {
//putstring("\nINVALID CHANNEL PASSED TO rbSendMessageHelper: "); putnum_uh(channel);
while (1) {
blinkRed(14);
blinkOrange(14);
}
}
disableRTC2();
if (pollClockLine(channel) == 0) {
//putstring("\n about to ATTEMPT TO RECEIVE BEFORE SENDING on channel: "); putnum_ud(channel);
ReceiveMessagePacket incomingPacket = receiveMessage(channel);
if (incomingPacket.messageLength != 0) {
//valid message, but it in the pending processing buffer
//putstring("\nReceived Message before sending on channel "); putnum_ud(channel);
//putstring(" Adding message to process pending queue");
addProcessPendingMsg(incomingPacket);
}
}
uint8_t i;
uint8_t good_tx = TRUE;
for (i = 0; i < messageLength; i++) {
if (sendByte(message[i], channel) == FALSE) {
//the message was not received.
//putstring("failed to send a byte");
good_tx = FALSE;
break;
}
else
good_tx = TRUE;
refreshChannel(channel); //able to send at least 1 byte
}
/*if (channel == 1 && !good_tx)
{
putstring("\nch1 send failure\n");
}*/
enableRTC2();
return good_tx;
}
开发者ID:chazmatazz,项目名称:proto-mirror,代码行数:48,代码来源:comm.c
示例15: receiveMessage
ReceiveMessageResponse*
SQSConnection::receiveMessage (const std::string &aQueueUrl,
int aNumberOfMessages,
int aVisibilityTimeout,
bool aDecode) {
ParameterMap lMap;
if (aNumberOfMessages != 0) {
std::stringstream s;
s << aNumberOfMessages;
lMap.insert (ParameterPair ("MaxNumberOfMessages", s.str()));
}
if (aVisibilityTimeout > -1) {
std::stringstream s;
s << aVisibilityTimeout;
lMap.insert (ParameterPair ("VisibilityTimeout", s.str()));
}
return receiveMessage (aQueueUrl, lMap, aDecode);
}
开发者ID:Zhangli88,项目名称:libaws,代码行数:19,代码来源:sqsconnection.cpp
示例16: while
int OsPooledTask::run(void* pArg)
{
while (!_isTerminated)
{
OsMsg* pMsg = 0;
if (OS_SUCCESS == receiveMessage((OsMsg*&) pMsg) && pMsg)
{
if (!_isTerminated)
{
if (_synchronizeHandler)
{
mutex_lock lock(_mutex);
handleMessage(*pMsg);
}
else
{
handleMessage(*pMsg);
}
}
}
else
{
break;
}
//
// Check if the request is a shutdown message
//
if (pMsg->getMsgType() == OsMsg::OS_SHUTDOWN)
{
if (!pMsg->getSentFromISR())
pMsg->releaseMsg();
break;
}
else if (!pMsg->getSentFromISR())
{
pMsg->releaseMsg(); // free the message
}
}
_isTerminated = true;
return 0;
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:43,代码来源:OsPooledTask.cpp
示例17: sendMessage
void ClientInterface::waitUntilReady(Checksum* checksum){
NetworkMessageReady networkMessageReady;
Chrono chrono;
chrono.start();
//send ready message
sendMessage(&networkMessageReady);
//wait until we get a ready message from the server
while(true){
NetworkMessageType networkMessageType= getNextMessageType();
if(networkMessageType==nmtReady){
if(receiveMessage(&networkMessageReady)){
break;
}
}
else if(networkMessageType==nmtInvalid){
if(chrono.getMillis()>readyWaitTimeout){
throw runtime_error("Timeout waiting for server");
}
}
else{
throw runtime_error("Unexpected network message: " + intToStr(networkMessageType) );
}
// sleep a bit
sleep(waitSleepTime);
}
//check checksum
if(Config::getInstance().getBool("NetworkConsistencyChecks")){
if(networkMessageReady.getChecksum()!=checksum->getSum()){
throw runtime_error("Checksum error, you don't have the same data as the server");
}
}
//delay the start a bit, so clients have nore room to get messages
sleep(GameConstants::networkExtraLatency);
}
开发者ID:wangtianhang,项目名称:glest,代码行数:43,代码来源:client_interface.cpp
示例18: QTcpSocket
Slave::Slave( const Ipc::Id &masterId, const Ipc::Id &slaveId ) :
QTcpSocket(),
m_slaveId( slaveId ),
m_pingTimer( this ),
m_lastPingResponse( QTime::currentTime() )
{
connect( this, SIGNAL( readyRead() ),
this, SLOT( receiveMessage() ) );
connect( this, SIGNAL( error( QAbstractSocket::SocketError ) ),
QCoreApplication::instance(), SLOT( quit() ) );
m_pingTimer.setInterval( 1000 );
connect( &m_pingTimer, SIGNAL( timeout() ),
this, SLOT( masterPing() ) );
connect( this, SIGNAL( connected() ),
&m_pingTimer, SLOT( start() ) );
connectToHost( QHostAddress::LocalHost, masterId.toInt() );
}
开发者ID:00farts,项目名称:italc-1,代码行数:19,代码来源:Slave.cpp
示例19: addr
void Summoners::on_btn_login_clicked()
{
quint32 port = ui.edit_port->text().toUInt();
QHostAddress addr(ui.edit_addr->text());
Socket = new QTcpSocket;
Socket->connectToHost(addr, port);
connect(Socket, SIGNAL(connected()), this, SLOT(processConnection()));
connect(Socket, SIGNAL(readyRead()), this, SLOT(receiveMessage()));
timer_heart = startTimer(1000); //假设每秒1次心跳。不同的游戏,心跳间隔不一样。
QByteArray datagram;
QDataStream iStream(&datagram, QIODevice::WriteOnly);
iStream.setByteOrder(QDataStream::LittleEndian);
iStream << CS_Login;
Socket->write(datagram);
}
开发者ID:simon0xia,项目名称:Summoners,代码行数:19,代码来源:summoners.cpp
示例20: QDialog
changepassword::changepassword(QWidget *parent) :
QDialog(parent),
ui(new Ui::changepassword)
{
ui->setupUi(this);
setWindowTitle("Change Password");
changesocket = new QTcpSocket(this);
buffer = new QBuffer(this);
buffer->open(QIODevice::ReadWrite);
connect(changesocket, SIGNAL(readyRead()), SLOT(receiveMessage()));
connect(this, SIGNAL(connectworked(QString*)), SLOT(sendMessage(QString*)));
connect(this, SIGNAL(logconnect()), SLOT(toggleConnection()));
connect(this, SIGNAL(receivedthis(string)), this , SLOT(checkiftrue(string)));
this->connect(ui->submit,SIGNAL(clicked()), this, SLOT(changepass()));
this->connect(ui->cancel,SIGNAL(clicked()), this, SLOT(cancel()));
}
开发者ID:aba617,项目名称:CryptChat,代码行数:19,代码来源:changepassword.cpp
注:本文中的receiveMessage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论