本文整理汇总了C++中OnReceive函数的典型用法代码示例。如果您正苦于以下问题:C++ OnReceive函数的具体用法?C++ OnReceive怎么用?C++ OnReceive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnReceive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _wtoi
void debugmodel::OnBnClickedButton4()
{
// TODO: 获取状态
char data[] = "1234567";
data[0] = ADDFIRST;
data[2] = ADDEND;
CString tmp;
m_garage_id.GetWindowText(tmp);
if (tmp == "")
return;
data[1] = _wtoi(tmp.GetBuffer(0));
data[3] = GETSTATE;
//m_row.GetWindowText(tmp);
data[4] = 0;// _wtoi(tmp.GetBuffer(0));
//m_col.GetWindowText(tmp);
data[5] = 0;// _wtoi(tmp.GetBuffer(0));
data[6] = (data[1] + data[3] + data[4] + data[5]) % CHECKMOD;
TESTPUTSEND
OnSend(data, 7);
Sleep(100);
memset(recstr, '\0', COMLEN);
OnReceive(recstr, 4);
TESTPUTRECN
//putinfo(recstr);
switch (recstr[1])
{
case STATEFREE:
m_state.SetWindowTextW(_T("空闲"));
break;
case STATESAVE:
m_state.SetWindowTextW(_T("存车"));
break;
case STATEDELETE:
m_state.SetWindowTextW(_T("取车"));
break;
case STATESTOP:
m_state.SetWindowTextW(_T("停止"));
break;
case STATERSET:
m_state.SetWindowTextW(_T("复位"));
break;
case ACCEPTED:
m_state.SetWindowTextW(_T("已接收"));
break;
case BUSY:
m_state.SetWindowTextW(_T("运行中"));
break;
default:
m_state.SetWindowTextW(_T("未知"));
}
}
示例2: switch
void CRealControlSocket::OnSocketEvent(wxSocketEvent &event)
{
if (!m_pBackend)
return;
if (event.GetId() != m_pBackend->GetId())
return;
switch (event.GetSocketEvent())
{
case wxSOCKET_CONNECTION:
m_onConnectCalled = true;
OnConnect();
break;
case wxSOCKET_INPUT:
if (!m_onConnectCalled)
{
m_onConnectCalled = true;
OnConnect();
}
OnReceive();
break;
case wxSOCKET_OUTPUT:
OnSend();
break;
case wxSOCKET_LOST:
OnClose();
break;
}
}
示例3: ContinueToReceiveSocketData
void hublistcollector::OnReceive(int error_code)
{
//error checking
if(error_code!=0)
{
p_dlg->StatusUpdate("Error Receiving Data");
}
if(m_receiving_socket_data || m_receiving_some_socket_data)
{
ContinueToReceiveSocketData();
return;
}
ReceiveSomeSocketData(1516);
char buf[1];
memset(buf,0,sizeof(buf));
WSABUF wsabuf;
wsabuf.buf=buf;
wsabuf.len=1;
DWORD num_read=0;
DWORD flags=MSG_PEEK;
int ret=WSARecv(m_hSocket,&wsabuf,1,&num_read,&flags,NULL,NULL);
if(ret!=SOCKET_ERROR)
{
if(num_read!=0)
{
OnReceive(0); // recursive call
}
}
}
示例4: main
int main()
{
{
//The Qt way
QtEmitter e;
QtReceiver r;
QObject::connect(&e,SIGNAL(signal_emit()),&r,SLOT(OnReceive()));
e.DoEmit();
}
{
//The Boost way
//Create the emitter and receiver
Emitter e;
Receiver r;
//The emitter is not yet connected to a receiver/slot
assert(e.m_signal.num_slots() == 0);
//Connect the emitter to a receiver/slot
e.m_signal.connect(
boost::bind(
&Receiver::OnReceive,r //Don't forget to put placeholders here (e.g. _1 ) if the signal have additional arguments
)
);
//The emitter is now connected to a receiver/slot
assert(e.m_signal.num_slots() == 1);
//Make the magic happen: the emitter puts out a signal and -unknown to it- the receiver responds
e.DoEmit();
}
assert(1==2);
}
示例5: OnDisconnect
void Session::handle_receive( const boost::system::error_code& error, size_t bytes_transferred )
{
if( error )
{
if( error == boost::asio::error::eof )
{
std::cout << "클라이언트와 연결이 끊어졌습니다" << std::endl;
}
else
{
std::cout << "error No: " << error.value() << " error Message: " << error.message() << std::endl;
}
_SessionDesc desc;
desc.sessionType = 0;
desc.identifier = 1;
m_pServer->CloseSession( m_nSessionID );
OnDisconnect(m_nSessionID, desc);
}
else
{
_SessionDesc desc;
desc.sessionType = 0;
desc.identifier = 1;
if (false == OnReceive(m_ReceiveBuffer.data(), bytes_transferred, desc))
{
//강제로 끊게 하는 메소드는?
}
PostReceive();
}
}
示例6: NetClientPoll
void NetClientPoll(NetClient *n)
{
if (!n->client || !n->peer)
{
return;
}
// Service the connection
int check;
do
{
ENetEvent event;
check = enet_host_service(n->client, &event, 0);
if (check < 0)
{
printf("Connection error %d\n", check);
return;
}
else if (check > 0)
{
switch (event.type)
{
case ENET_EVENT_TYPE_RECEIVE:
OnReceive(n, event);
break;
default:
printf("Unexpected event type %d\n", event.type);
break;
}
}
} while (check > 0);
}
示例7: HIWORD
/**
* Application must call this if a WM_ is coming from network.
*/
HRESULT ACWinSock::MsgProc(WPARAM wp, LPARAM lp)
{
WORD wEvent, wError;
// get data
wError = HIWORD(lp);
wEvent = LOWORD(lp);
// which event
switch (wEvent)
{
// confirmacao depois de uma conexao bem sucedida
case FD_CONNECT: break;
// cliente quer aceitacao
case FD_ACCEPT: { return OnAccept(); } break;
// recebemos algo
case FD_READ: { return OnReceive(wp); } break;
// um cliente ficou offline
case FD_CLOSE: { return OnDisconnect(wp); } break;
// nos mandamos algo?
case FD_WRITE: break;
}
return AC_OK;
};
示例8: HIWORD
// NOTE: Since the old WSAAsync functionality has been exchanged in the favor of WSAEvent, I'm not sure if MsgProc will fire correctly
HRESULT ZFXWS::MsgProc( WPARAM wp, LPARAM lp )
{
WORD wEvent, wError;
wError = HIWORD(lp);
wEvent = LOWORD(lp);
//evaluate what event occurred
switch ( wEvent )
{
//new client accepted
case FD_CONNECT:
break;
//new client is knocking
case FD_ACCEPT:
return OnAccept();
break;
//there is data to be received
case FD_READ:
return OnReceive(wp);
break;
//a socket is closing
case FD_CLOSE:
return OnDisconnect(wp);
break;
//after sending data
case FD_WRITE:
break;
}
return ZFX_OK;
}
示例9: Close
void CExternalIpCheck::OnConnect(int nErrorCode)
{
if (!m_bActive)
return;
if (nErrorCode)
{
m_bActive = FALSE;
Close();
m_nRetryCount++;
return;
}
CStdStringA address = "GET " + m_pOwner->m_pOptions->GetOption(OPTION_CUSTOMPASVIPSERVER) + " HTTP/1.0\r\nUser-Agent: FileZilla Server\r\n\r\n";
const char *buffer = address;
int len = strlen(buffer);
if (Send(buffer, len) != len)
{
m_bActive = FALSE;
Close();
m_nRetryCount++;
}
OnReceive(0);
}
示例10: while
void CExternalIPResolver::OnSend()
{
while (m_pSendBuffer)
{
unsigned int len = strlen(m_pSendBuffer + m_sendBufferPos);
int error;
int written = m_pSocket->Write(m_pSendBuffer + m_sendBufferPos, len, error);
if (written == -1)
{
if (error != EAGAIN)
Close(false);
return;
}
if (!written)
{
Close(false);
return;
}
if (written == (int)len)
{
delete [] m_pSendBuffer;
m_pSendBuffer = 0;
OnReceive();
}
else
m_sendBufferPos += written;
}
}
示例11: QObject
Client::Client(QObject *parent) : QObject(parent)
{
socket = new QTcpSocket(this);
connect(this->socket, SIGNAL(readyRead()),this, SLOT(OnReceive()));
m_hostmessref=0;
}
示例12: LOG
void L2Socket::HandleAccept( tcp::socket& _socket, boost::system::error_code _ec )
{
if (!acceptor->is_open() )
{
LOG( "HandleAccept acceptor !is_open()!!!" );
return ;
}
if( _ec )
{
LOG( "HandleAccept error: "+ _ec.message() );
Disconnect(_socket);
return;
}
LOG( "HandleAccept New Connect ip: "+_socket.remote_endpoint().address().to_string() + " port: " + _socket.remote_endpoint().port());
//tcp::no_delay option(true);
//_socket.set_option(option);
shared_ptr<L2Actor> _act = L2_GET_UNUSED_OBJ(L2Actor);
SERVER->PushActor( _act->OID );
_act->GetAgent()->SetConnect(true);
sockAry.push_back(&_socket);
agentOIDAry.push_back( _act->GetAgent()->OID );
if( bWebSocket )
OnHandshake(_socket,_act->GetAgent()->OID);
else
OnReceive( _socket,_act->GetAgent()->OID );
//THREAD->ThreadSleepFPS();
OnAccept();
}
示例13: switch
HRESULT CClientWizard::DirectPlayMessageHandler(PVOID pvUserContext, DWORD dwMessageID, PVOID pMsgBuffer)
{
HRESULT hr = S_OK;
switch(dwMessageID)
{
case DPN_MSGID_ASYNC_OP_COMPLETE:
hr = OnAsyncOpComplete(pMsgBuffer);
break;
case DPN_MSGID_CONNECT_COMPLETE:
hr = OnConnectComplete(pMsgBuffer);
break;
case DPN_MSGID_ENUM_HOSTS_RESPONSE:
hr = OnHostsResponse(pMsgBuffer);
break;
case DPN_MSGID_TERMINATE_SESSION:
// hr = OnTerminateSession(pMsgBuffer);
break;
case DPN_MSGID_RECEIVE:
OnReceive(pMsgBuffer);
break;
default:
break;
}
return hr;
}
示例14: ASSERT
void CEC_LogicalDevice::OnReceiveComplete(unsigned char* buffer, int count)
{
ASSERT(count >= 1);
int sourceAddress = (buffer[0] >> 4) & 0x0f;
int targetAddress = buffer[0] & 0x0f;
OnReceive(sourceAddress, targetAddress, buffer + 1, count - 1);
}
示例15: ContinueToReceiveSocketData
void DCDownload::OnReceive(int error_code)
{
if(error_code!=0)
{
return; //return due to error
}
if(m_receiving_socket_data || m_receiving_some_socket_data)
{
ContinueToReceiveSocketData();
return;
}
ReceiveSomeSocketData(1516);
char buf[1];
memset(buf,0,sizeof(buf));
WSABUF wsabuf;
wsabuf.buf=buf;
wsabuf.len=1;
DWORD num_read=0;
DWORD flags=MSG_PEEK;
int ret=WSARecv(m_hSocket,&wsabuf,1,&num_read,&flags,NULL,NULL);
if(ret!=SOCKET_ERROR)
{
if(num_read!=0)
{
OnReceive(0); // recursive call
}
}
//::AfxMessageBox("Received Message");
}