本文整理汇总了C++中ReceiveMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ ReceiveMessage函数的具体用法?C++ ReceiveMessage怎么用?C++ ReceiveMessage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReceiveMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strcpy
int FtpClient::Login()
{
try
{
char buffer[2048];
int code;
strcpy ( buffer, "USER " );
strcat ( buffer, this->userName );
if(!SendMessage ( buffer ))
{
perror("Can't send message\n");
return 1;
}
strcpy ( buffer, ReceiveMessage() ); //receiving confirmation
code = GetCode ( buffer );
if ( code != 331 ) //if the FTP server sent a code that it's not 331, than we've got problems
return code;
strcpy ( buffer, "PASS " );
strcat ( buffer, password );
SendMessage ( buffer ); //now we have to send the password
strcpy ( buffer, ReceiveMessage() );
code = GetCode ( buffer );
Sock = _Socket;
if ( code != 230 ) //if something went wrong, then we send the code back to the calling function
return code;
}
catch ( Exception ex )
{
cout << ex.Message;
}
return 0; //this means that we are logged in
}
示例2: test_t2_instance
/*test case:test the reaction of the system called with
an activation of a task*/
static void test_t2_instance(void)
{
StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5;
StatusType received_char;
SCHEDULING_CHECK_INIT(11);
result_inst_1 = GetMessageStatus(rm);
SCHEDULING_CHECK_AND_EQUAL_INT(13,E_COM_ID, result_inst_1);
SCHEDULING_CHECK_INIT(14);
result_inst_2 = ReceiveMessage(rm, &received_char);
SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(14,E_OK, result_inst_2);
SCHEDULING_CHECK_AND_EQUAL_INT(14,(int)('1'), (int)received_char);
SCHEDULING_CHECK_INIT(15);
result_inst_3 = ReceiveMessage(rm, &received_char);
SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(15,E_OK, result_inst_3);
SCHEDULING_CHECK_AND_EQUAL_INT(15,(int)('1'), (int)received_char);
SCHEDULING_CHECK_INIT(16);
result_inst_4 = ReceiveMessage(INVALID_MESSAGE, &received_char);
SCHEDULING_CHECK_AND_EQUAL_INT(19,E_COM_ID, result_inst_4);
SCHEDULING_CHECK_INIT(20);
result_inst_5 = TerminateTask();
SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK, result_inst_5);
}
示例3: switch
//this_ui_add_start
bool CUIPointInitDlg::OnKeyPress(int iKey)
{
switch(iKey)
{
case DIK_RETURN:
ReceiveMessage(m_pBtn_Ok, UIMSG_BUTTON_CLICK);
return true;
case DIK_ESCAPE:
ReceiveMessage(m_pBtn_Cancel, UIMSG_BUTTON_CLICK);
return true;
}
return CN3UIBase::OnKeyPress(iKey);
}
示例4: switch
bool CUIWarp::OnKeyPress(int iKey)
{
switch(iKey)
{
case SDL_SCANCODE_ESCAPE://DIK_ESCAPE:
ReceiveMessage(m_pBtn_Cancel, UIMSG_BUTTON_CLICK);
return true;
case SDL_SCANCODE_RETURN://DIK_RETURN:
ReceiveMessage(m_pBtn_Ok, UIMSG_BUTTON_CLICK);
return true;
}
return CN3UIBase::OnKeyPress(iKey);
}
示例5: LOG
int MsgQueueConnection::recv(uint num_bytes, char *dest, uint /*non_blocking_read_ahead*/)
{
if (!is_connected())
{
LOG("SKYPE ERROR - LocalServerConnection::recv(), not connected");
return -1;
}
uint nBytesRead = 0;
while (nBytesRead < num_bytes)
{
if (m_iReadIndex >= m_cBuffer.len)
{
if (ReceiveMessage() == false) return -1;
m_iReadIndex = 0;
}
uint n = min((uint)m_cBuffer.len - m_iReadIndex, num_bytes-nBytesRead);
Mem::Copy(dest, m_cBuffer.msg+m_iReadIndex, n);
m_iReadIndex += n;
nBytesRead += n;
}
return nBytesRead;
}
示例6: ProcessWriteFile
void ProcessWriteFile(int sock, std::string pathFile,size_t offset,std::string buffer) {
std::cout << "ProcessWriteFile \n";
std::stringstream ss;
ss << WRITEFILE_REQUEST << pathFile << "," << offset << "," << buffer;
Message mesToSend, mesToReceive;
mesToSend.typeMes = Text;
mesToSend.content = ss.str();
mesToSend.sizeMes = mesToSend.content.size();
std::cout << "send - " << mesToSend.content << std::endl;
SendMessage(sock, mesToSend);
/* Receiving result read file */
ReceiveMessage(sock, mesToReceive);
if (mesToReceive.typeMes != Binary) {
std::cout << "Server invalid \n";
return;
}
ResultCode rc = (ResultCode)(*(BYTE*)mesToReceive.content.data());
if (rc == Success) {
std::cout << "Success \n";
} else {
std::cout << "Fail \n";
}
}
示例7: ProcessGetListEntry
void ProcessGetListEntry(int sock, std::string pathDir) {
std::cout << "ProcessGetListEntry \n";
Message mesToSend, mesToReceive;
mesToSend.typeMes = Text;
mesToSend.content = GETLISTENTRY_REQUEST + pathDir;
mesToSend.sizeMes = mesToSend.content.size();
std::cout << "send - " << mesToSend.content << std::endl;
SendMessage(sock, mesToSend);
ReceiveMessage(sock,mesToReceive);
if (mesToReceive.typeMes != Text) {
std::cout << "Server invalid (1).\n";
return;
}
std::cout << mesToReceive.content << std::endl;
std::vector<std::string> array_str;
int numberEntry = Split(mesToReceive.content, array_str, ";");
if (numberEntry > 0) {
for (int i = 0; i < numberEntry; i++) {
std::vector<std::string> entry_type;
int size = Split(array_str[i],entry_type,"=");
if (size == 2) {
std::cout << entry_type[0] << " is " << entry_type[1] << std::endl;
}
}
}
}
示例8: bzero
char *FtpClient::GetCurrentDirectory()
{
try
{
char buffer[2048];
bzero ( buffer, 2048 );
SendMessage ( "PWD" );
strcpy ( buffer, ReceiveMessage() );
int code = GetCode ( buffer );
if ( code == 257 )
{
int i = 0;
for ( i = 0; i < strlen ( buffer ) && buffer[i] != '\"'; i++ );
char dir[2048];
bzero ( dir, 2048 );
strcpy ( dir, buffer + ( i + 1 ) );
for ( i = 0; i < strlen ( dir ) && dir[i] != '\"'; i++ );
dir[i] = '\0';
return dir;
}
else
return "error";
}
catch ( Exception ex )
{
cout << ex.Message;
return ex.Message;
}
}
示例9: GetSender
void
War2Wiz::Receive
(
JBroadcaster* sender,
const Message& message
)
{
if (message.Is(JMessageProtocolT::kMessageReady))
{
JIndex senderIndex;
WarSocket* socket = GetSender(sender, &senderIndex);
ReceiveMessage(senderIndex, *socket);
}
else if (message.Is(JMessageProtocolT::kReceivedDisconnect))
{
ReceiveDisconnect(sender, kJFalse);
}
else if (message.Is(WarSocket::kTimeout))
{
ReceiveDisconnect(sender, kJTrue);
}
else
{
JBroadcaster::Receive(sender, message);
}
}
示例10: receiveRequests
void receiveRequests()
{
// service ready
klog("spawner server ready");
// defining size for messages
const size_t requestLenMax = sizeof(MessageHeader) + sizeof(SpawnCommandSpawnRequest) + 1024;
while (true)
{
// creating buffer for message
uint8_t requestBuffer[requestLenMax];
// receive incoming request
MessageReceiveStatus stat = ReceiveMessage(requestBuffer, requestLenMax);
if (stat != MESSAGE_RECEIVE_STATUS_SUCCESSFUL) protocolError("receiving command failed with code %i", stat);
MessageHeader *header = (MessageHeader*) requestBuffer;
SpawnCommandHeader *commandHeader = (SpawnCommandHeader*) MESSAGE_CONTENT(header);
if (commandHeader->command == SPAWN_COMMAND_SPAWN_REQUEST) processSpawnRequest((SpawnCommandSpawnRequest*) commandHeader, header->sender, header->transaction);
else if (commandHeader->command == SPAWN_COMMAND_SHUTDOWN_MACHINE || commandHeader->command == SPAWN_COMMAND_REBOOT_MACHINE) processHealtMachine(commandHeader->command);
else protocolError("received unknown command: code %i, task %i", commandHeader->command, header->sender);
}
}
示例11: HandleMessage
void CommThread :: HandleMessage( Message * pcMessage )
{
switch( pcMessage->GetCode() )
{
case MSG_TOLOOPER_START:
{
SendReceiveLoop();
break;
}
case MSG_TOLOOPER_RECEIVE:
{
ReceiveMessage();
break;
}
case MSG_TOLOOPER_SEND:
{
SendMessage();
break;
}
default:
Looper::HandleMessage( pcMessage );
break;
}
}
示例12: MakeFileData
bool SendTransaction::RequestId()
{
QByteArray fileData;
MakeFileData(fileData);
if (!TransmitMessage(State::Request::REQUEST_PERMISSION, fileData))
{
emit TransmissionFailed(State::Error::ID_RECEIVING_FAILED);
return false;
}
Message msg;
if (!ReceiveMessage(msg))
{
emit TransmissionFailed(State::Error::ID_RECEIVING_FAILED);
return false;
}
if (msg.state == State::Response::TRANSMISSION_DECLINED)
{
emit TransmissionCancelled();
return false;
}
if (msg.state != State::Response::RESP_ID)
{
emit TransmissionFailed(State::Error::ID_RECEIVING_FAILED);
return false;
}
MakePeerData(msg, addr_, port_);
id_ = msg.id;
return true;
}
示例13: if
bool CUILogIn::ReceiveMessage(CN3UIBase* pSender, DWORD dwMsg)
{
if(NULL == pSender) return false;
//s_CameraData.vp; //불러 오는 과정을 살펴본다
//DWORD mm = s_CameraData.vp.Height;
//DWORD ss = s_CameraData.vp.Width;
if (dwMsg == UIMSG_BUTTON_CLICK)
{
if (pSender == m_pBtn_LogIn && m_pEdit_id && m_pEdit_pw)
{
CGameProcedure::s_pProcLogIn->MsgSend_AccountLogIn(LIC_KNIGHTONLINE);
}
else if(pSender == m_pBtn_Connect)
{
CGameProcedure::s_pProcLogIn->ConnectToGameServer(); // 고른 게임 서버에 접속
}
else if (pSender == m_pBtn_Cancel)
{
//PostQuitMessage(0); // 종료...
CGameBase::s_bRunning = false;
}
else if(pSender == m_pBtn_Option) // 옵션..
{
std::string szMsg;
szMsg = "Would you like to open the options?";//::_LoadStringFromResource(IDS_CONFIRM_EXECUTE_OPTION, szMsg);
CGameProcedure::MessageBoxPost(szMsg, "", MB_YESNO, BEHAVIOR_EXECUTE_OPTION);
}
}
else if(UIMSG_LIST_DBLCLK == dwMsg)
{
CGameProcedure::s_pProcLogIn->ConnectToGameServer(); // 고른 게임 서버에 접속
}
else if (dwMsg == UIMSG_EDIT_RETURN)
{
// TEMP(srmeier): there is a weird issue where the key inputs aren't going
// through CGameProcedure::ProcessUIKeyInput() so CUILogIn::OnKeyPress() isn't
// being called...
if(!m_bLogIn && m_pEdit_id && m_pEdit_pw)
{
CN3UIBase* pMsgBox = CGameProcedure::s_pMsgBoxMgr->GetFocusMsgBox();
if( !(pMsgBox && pMsgBox->IsVisible()) )
CGameProcedure::s_pProcLogIn->MsgSend_AccountLogIn(LIC_KNIGHTONLINE);
}
else {
ReceiveMessage(m_pBtn_Connect, UIMSG_BUTTON_CLICK);
}
}
else if (dwMsg == UIMSG_EDIT_TAB)
{
// TEMP(srmeier): there is a weird issue where the key inputs aren't going
// through CGameProcedure::ProcessUIKeyInput() so CUILogIn::OnKeyPress() isn't
// being called...
FocusCircular();
}
return true;
}
示例14: while
void Aggregator::ClearMessageQueue()
{
myDPID from;
DWORD BufferLen;
char* Buffer;
while (ReceiveMessage(Buffer,BufferLen,from)==DP_OK) {}
}
示例15: SendReceiveMessage
//======================================================
// Send a message to a message port and wait for a reply
//======================================================
void SendReceiveMessage(struct MessagePort *MP, struct Message *Msg)
{
struct MessagePort *tempMP = AllocMessagePort();
Msg->tempPort = tempMP;
SendMessage(MP, Msg);
ReceiveMessage(tempMP, Msg);
DeallocMem(tempMP);
}