本文整理汇总了C++中wxSocketEvent类的典型用法代码示例。如果您正苦于以下问题:C++ wxSocketEvent类的具体用法?C++ wxSocketEvent怎么用?C++ wxSocketEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxSocketEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OnSocketEvent
void FaceView::OnSocketEvent(wxSocketEvent& event)
{
wxSocketBase *sock = event.GetSocket();
static int test = 0;
// Now we process the event
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT:
{
wxString msg;
msg.sprintf(_T("input id: %d"), ++test);
sock->SaveState();
// sock->SetNotify(wxSOCKET_LOST_FLAG);
wxLogStatus(msg, 0);
ServerThread* pThread = new ServerThread(/*this, */m_pApp, sock);
pThread->Create();
pThread->Run();
sock->RestoreState();
//sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
break;
}
case wxSOCKET_LOST:
{
if(!m_SocketIdHash.erase(sock))
{
//sth weird going on, LOG IT!
}
sock->Destroy();
wxLogStatus(wxT("Remote client connection closed."));
break;
}
default: ;
}
}
开发者ID:bestdpf,项目名称:xface-error,代码行数:35,代码来源:FaceView.cpp
示例2: switch
// Handle Commands from debugger (and lost connections)
void wxLuaDebuggerwxSocketServer::OnSocketEvent(wxSocketEvent& event)
{
wxSocketBase *sock = event.GetSocket();
// Now we process the event
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT:
{
// We disable input events, so that the test doesn't trigger
// wxSocketEvent again.
sock->SetNotify(wxSOCKET_LOST_FLAG);
unsigned char debugEvent = 0; // wxLuaDebuggeeEvents_Type
if (m_acceptedSocket->ReadCmd(debugEvent))
HandleDebuggeeEvent(debugEvent);
// Enable input events again.
sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
break;
}
case wxSOCKET_LOST:
{
m_acceptedSocket->Destroy();
delete m_acceptedSocket;
m_acceptedSocket = NULL;
break;
}
default:
// Error
break;
}
}
开发者ID:oeuftete,项目名称:wx-xword,代码行数:34,代码来源:wxldserv.cpp
示例3: OnSocketEvent
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;
}
}
开发者ID:idgaf,项目名称:FileZilla3,代码行数:30,代码来源:ControlSocket.cpp
示例4: OnSockRequest
void WinEDA_DrawFrame::OnSockRequest(wxSocketEvent& evt)
/********************************************************/
/* Fonction appelee a chaque demande d'un client
*/
{
size_t len;
wxSocketBase *sock = evt.GetSocket();
switch (evt.GetSocketEvent())
{
case wxSOCKET_INPUT:
sock->Read(server_ipc_buffer,1);
len = sock->Read(server_ipc_buffer+1,IPC_BUF_SIZE-2).LastCount();
server_ipc_buffer[len+1] = 0;
if(RemoteFct ) RemoteFct(server_ipc_buffer);
break;
case wxSOCKET_LOST:
return;
break;
default:
wxPrintf( wxT("WinEDA_DrawFrame::OnSockRequest() error: Invalid event !"));
break;
}
}
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:26,代码来源:eda_dde.cpp
示例5: OnSockRequest
/* Function called on every client request.
*/
void EDA_DRAW_FRAME::OnSockRequest( wxSocketEvent& evt )
{
size_t len;
wxSocketBase* sock = evt.GetSocket();
switch( evt.GetSocketEvent() )
{
case wxSOCKET_INPUT:
sock->Read( client_ipc_buffer, 1 );
if( sock->LastCount() == 0 )
break; // No data, occurs on opening connection
sock->Read( client_ipc_buffer + 1, IPC_BUF_SIZE - 2 );
len = 1 + sock->LastCount();
client_ipc_buffer[len] = 0;
ExecuteRemoteCommand( client_ipc_buffer );
break;
case wxSOCKET_LOST:
return;
break;
default:
wxPrintf( wxT( "EDA_DRAW_FRAME::OnSockRequest() error: Invalid event !" ) );
break;
}
}
开发者ID:Caerbannog,项目名称:kicad-git-bzr,代码行数:30,代码来源:eda_dde.cpp
示例6: ProxySocketHandler
void CProxyEventHandler::ProxySocketHandler(wxSocketEvent& event)
{
CProxySocket *sock = dynamic_cast<CProxySocket *>(event.GetSocket());
if (sock) {
sock->m_proxyStateMachine->Schedule(event.GetSocketEvent());
} else {
// we're doomed :)
}
sock->m_proxyStateMachine->Clock();
}
开发者ID:windreamer,项目名称:amule-dlp,代码行数:10,代码来源:Proxy.cpp
示例7: OnSocketEvent
void wxMainFrame::OnSocketEvent(wxSocketEvent& event)
{
if (event.GetSocketEvent()==wxSOCKET_INPUT)
{
// m_TEDProtocol->GetSocketData();
}
else if (event.GetSocketEvent()==wxSOCKET_LOST)
{
::wxMessageBox(_("Se perdió la conexión con el servidor.\nEl cliente se cerrará."));
Close();
}
}
开发者ID:BackupTheBerlios,项目名称:nted-svn,代码行数:12,代码来源:mainframe.cpp
示例8: _
void wxScopeServerDialog::OnSocketEvent(wxSocketEvent& event)
{
wxString s = _("OnSocketEvent: ");
wxSocketBase *sock = event.GetSocket();
/*
// First, print a message
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT : s.Append(_("wxSOCKET_INPUT\n")); break;
case wxSOCKET_LOST : s.Append(_("wxSOCKET_LOST\n")); break;
default : s.Append(_("Unexpected event !\n")); break;
}
Tx_ServerLog->AppendText(s);
*/
// Now we process the event
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT:
{
// We disable input events, so that the test doesn't trigger
// wxSocketEvent again.
sock->SetNotify(wxSOCKET_LOST_FLAG);
if (!m_server->HandleINPUT(sock)) // delegate input handling to class
Tx_ServerLog->AppendText(_("HandleINPUT failed\n"));
// Enable input events again.
sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
break;
}
case wxSOCKET_LOST:
{
m_numClients--;
// Destroy() should be used instead of delete wherever possible,
// due to the fact that wxSocket uses 'delayed events' (see the
// documentation for wxPostEvent) and we don't want an event to
// arrive to the event handler (the frame, here) after the socket
// has been deleted. Also, we might be doing some other thing with
// the socket at the same time; for example, we might be in the
// middle of a test or something. Destroy() takes care of all
// this for us.
Tx_ServerLog->AppendText(_("Closing socket.\n\n"));
sock->Notify(false);
sock->Destroy();
break;
}
default: ;
}
}
开发者ID:MarekTP,项目名称:wxAstroCapture,代码行数:53,代码来源:wxScopeServerMain.cpp
示例9: OnSocketEvent
void tracelogApp::OnSocketEvent(wxSocketEvent& event)
{
wxSocketBase *sock = event.GetSocket();
if (wxSOCKET_LOST == event.GetSocketEvent()) {
sock->Notify(false);
std::map<wxSocketBase *, wxSocketOutputStream *>::iterator it = m_mClients.find(sock);
if (m_mClients.end() != it) {
delete it->second;
m_mClients.erase(it);
}
sock->Destroy();
}
}
开发者ID:aidan-g,项目名称:opennx,代码行数:13,代码来源:tracelogApp.cpp
示例10: wxASSERT
void CTlsSocket::OnSocketEvent(wxSocketEvent& event)
{
wxASSERT(m_pSocket);
if (!m_session)
return;
if (event.GetId() != m_pSocketBackend->GetId())
return;
switch (event.GetSocketEvent())
{
case wxSOCKET_INPUT:
OnRead();
break;
case wxSOCKET_OUTPUT:
OnSend();
break;
case wxSOCKET_LOST:
{
m_canCheckCloseSocket = true;
char tmp[100];
m_pSocketBackend->Peek(&tmp, 100);
if (!m_pSocketBackend->Error())
{
int lastCount = m_pSocketBackend->LastCount();
if (lastCount)
m_pOwner->LogMessage(Debug_Verbose, _T("CTlsSocket::OnSocketEvent(): pending data, postponing wxSOCKET_LOST"));
else
m_socketClosed = true;
OnRead();
if (lastCount)
return;
}
m_pOwner->LogMessage(Debug_Info, _T("CTlsSocket::OnSocketEvent(): wxSOCKET_LOST received"));
//Uninit();
wxSocketEvent evt(GetId());
evt.m_event = wxSOCKET_LOST;
wxPostEvent(m_pEvtHandler, evt);
}
break;
default:
break;
}
}
开发者ID:idgaf,项目名称:FileZilla3,代码行数:48,代码来源:tlssocket.cpp
示例11: OnSocketEvent
void CslUDP::OnSocketEvent(wxSocketEvent& event)
{
if (event.GetSocketEvent()!=wxSOCKET_INPUT)
return;
wxIPV4address addr;
wxUint32 size;
CslUDPPacket *packet=new CslUDPPacket(CSL_MAX_PACKET_SIZE);
m_socket->RecvFrom(addr,packet->Data(),CSL_MAX_PACKET_SIZE);
if (m_socket->Error())
{
packet->FreeData();
#ifndef __WXMSW__
LOG_DEBUG("Error receiving packet: %s\n",U2A(GetSocketError(m_socket->LastError())));
#endif
}
size=m_socket->LastCount();
packet->SetAddr(addr);
packet->SetSize(size);
m_bytesIn+=size;
m_packetsIn++;
wxCommandEvent evt(wxCSL_EVT_PING);
evt.SetClientData(packet);
wxPostEvent(m_evtHandler,evt);
}
开发者ID:MorganBorman,项目名称:Cube-Server-Lister,代码行数:29,代码来源:CslUDP.cpp
示例12: OnServerEvent
void FaceView::OnServerEvent(wxSocketEvent& event)
{
wxString s;
wxSocketBase *sock = 0;
if(event.GetSocketEvent() != wxSOCKET_CONNECTION)
return;
// Accept new connection if there is one in the pending
// connections queue, else exit. We use Accept(FALSE) for
// non-blocking accept (although if we got here, there
// should ALWAYS be a pending connection).
sock = m_pServer->Accept(false);
if (sock)
{
wxLogStatus(_T("New client connection accepted"), 0);
m_SocketIdHash[sock] = ++m_clientCount; // add socket to map of connected clients
// Notify the client
Notification note("CONNECTION_OK", m_clientCount);
fireNotification(note);
}
else
return;
sock->SetEventHandler(*this, Socket_event);
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
sock->Notify(TRUE);
}
开发者ID:sub77,项目名称:hobbycode,代码行数:30,代码来源:FaceView.cpp
示例13: OnSocketEvent
void CslUDP::OnSocketEvent(wxSocketEvent& event)
{
if (event.GetSocketEvent()!=wxSOCKET_INPUT)
return;
wxInt32 read;
wxIPV4address addr;
CslNetPacket *packet = CslNetPacket::Create();
packet->Alloc(CSL_MAX_PACKET_SIZE);
if (m_socket->RecvFrom(addr, packet->Data(), CSL_MAX_PACKET_SIZE).Error())
{
#ifndef __WXMSW__
CSL_LOG_DEBUG("error RecvFrom() failed. (%s)\n",
U2C(GetSocketError(m_socket->LastError())));
#endif
CslNetPacket::Destroy(packet, true);
return;
}
if ((read = m_socket->LastCount())==0)
{
CslNetPacket::Destroy(packet, true);
return;
}
packet->SetAddr(addr);
packet->SetSize(read);
m_bytesIn += read;
m_packetsIn++;
CslPingEvent evt(packet);
wxPostEvent(m_evtHandler, evt);
}
开发者ID:aurhat,项目名称:cubelister,代码行数:35,代码来源:CslUDP.cpp
示例14: OnSocketEvent
void SocketEvents::OnSocketEvent(wxSocketEvent& event)
{
Socket* sock = (Socket*)event.GetClientData();
if (sock == NULL) {
m_net_class.OnError(_T("sock = 0"));
return;
}
if ( event.GetSocketEvent() == wxSOCKET_INPUT ) {
m_net_class.OnDataReceived( *sock );
} else if ( event.GetSocketEvent() == wxSOCKET_LOST ) {
m_net_class.OnDisconnected( *sock );
} else if ( event.GetSocketEvent() == wxSOCKET_CONNECTION ) {
m_net_class.OnConnected( *sock );
} else {
m_net_class.OnError(_T("Unknown socket event."));
}
}
开发者ID:jgleesawn,项目名称:springlobby,代码行数:18,代码来源:socket.cpp
示例15: OnSocketEvent
void kitchenFrame::OnSocketEvent(wxSocketEvent& event)
{
wxSocketBase *sock = event.GetSocket();
switch(event.GetSocketEvent())
{
case wxSOCKET_CONNECTION:
{
// wxMessageBox(_("Connected!"));
break;
}
case wxSOCKET_INPUT:
{
sock->SetNotify(wxSOCKET_LOST_FLAG);
unsigned char c;
sock->Read(&c, 1);
switch (c)
{
case 0xBE:
readFromDining(sock);
break; //this means we are receiving something from dining room f.e. new order
// case 0xCE: Test2(sock); break;
// case 0xDE: Test3(sock); break;
}
sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
break;
}
case wxSOCKET_LOST:
{
// wxMessageBox(_("DisConnected!"));
StatusBar1->SetStatusText(_("Lost connection."),1);
// sock->Destroy();
sock->Close();
break;
}
default:
;
}
}
开发者ID:Leonti,项目名称:estescook,代码行数:44,代码来源:kitchenMain.cpp
示例16: OnSocketEvent
void wxGISLocalClientConnection::OnSocketEvent(wxSocketEvent& event)
{
event.Skip(false);
wxLogDebug(wxT("wxClientTCPNetConnection: event"));
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT:
wxLogDebug(wxT("wxClientTCPNetConnection: INPUT"));
break;
case wxSOCKET_OUTPUT:
wxLogDebug(wxT("wxClientTCPNetConnection: OUTPUT"));
break;
case wxSOCKET_CONNECTION:
wxLogDebug(wxT("wxClientTCPNetConnection: CONNECTION"));
m_bIsConnected = true;
m_bIsConnecting = false;
{
wxNetMessage msgin(enumGISNetCmdHello, enumGISNetCmdStUnk, enumGISPriorityHighest);
wxGISNetEvent event(0, wxGISNET_MSG, msgin);
PostEvent(event);
}
break;
case wxSOCKET_LOST:
wxLogDebug(wxT("wxClientTCPNetConnection: LOST"));
{
wxNetMessage msgin(enumGISNetCmdBye, enumGISNetCmdStUnk, enumGISPriorityHighest);
if(!m_bIsConnected && m_bIsConnecting)
{
m_bIsConnecting = false;
}
else
{
m_bIsConnected = false;
}
wxGISNetEvent event(0, wxGISNET_MSG, msgin);
PostEvent(event);
}
break;
default:
wxLogDebug(wxT("wxClientTCPNetConnection: default"));
break;
}
}
开发者ID:Mileslee,项目名称:wxgis,代码行数:43,代码来源:tskmngr.cpp
示例17: OnSocketEvent
void SocketEvents::OnSocketEvent(wxSocketEvent& event)
{
Socket* sock = (Socket*)event.GetClientData();
try
{
ASSERT_LOGIC( sock != 0, _T("sock = 0") );
} catch (...) { return; }
if ( event.GetSocketEvent() == wxSOCKET_INPUT ) {
m_net_class.OnDataReceived( sock );
} else if ( event.GetSocketEvent() == wxSOCKET_LOST ) {
m_net_class.OnDisconnected( sock );
} else if ( event.GetSocketEvent() == wxSOCKET_CONNECTION ) {
m_net_class.OnConnected( sock );
} else {
try
{
ASSERT_LOGIC( false, _T("Unknown socket event."));
} catch (...) { return; };
}
}
开发者ID:SpliFF,项目名称:springlobby,代码行数:21,代码来源:socket.cpp
示例18: HandleEvent
void RMENet::HandleEvent(wxSocketEvent& evt)
{
NetworkConnection* connection = reinterpret_cast<NetworkConnection*>(evt.GetClientData());
switch(evt.GetSocketEvent())
{
case wxSOCKET_LOST:
// Connection was lost, either client disconnecting, or our socket breaking
{
// Generate event
wxCommandEvent event(EVT_RMENET_CONNECTION_LOST);
event.SetInt(0);
event.SetString("GOOOFU");
event_dump->AddPendingEvent(event);
} break;
case wxSOCKET_OUTPUT:
// We're ready to write to a socket
{
// Send waiting data
connection->Send();
} break;
case wxSOCKET_INPUT:
// We got some data to be read.
{
NetworkMessage* nmsg = connection->Receive();
if(nmsg)
{
try
{
OnParsePacket(nmsg);
FreeMessage(nmsg);
}
catch(std::runtime_error&)
{
FreeMessage(nmsg);
Close();
}
}
} break;
}
}
开发者ID:TheSumm,项目名称:rme,代码行数:40,代码来源:rme_net.cpp
示例19: OnServerEvent
/*!
* Handler for Server events (before connection)
*
* - Only expects connection events wxSOCKET_CONNECTION
* - Creates new socket and adds handler for socket events
*
* @param event Event to handle
*/
void GdbServerWindow::OnServerEvent(wxSocketEvent& event) {
if (event.GetSocketEvent() != wxSOCKET_CONNECTION) {
statusTextControl->AppendText(_("Unexpected event on Server\n"));
// Ignore
return;
}
if (clientSocket != NULL) {
statusTextControl->AppendText(_("Client connection while busy - rejected\n"));
wxSocketBase *clientSocket = serverSocket->Accept(false);
clientSocket->Destroy();
return;
}
// Accept new connection if there is one in the pending
// connections queue, else exit. We use Accept(false) for
// non-blocking accept (although if we got here, there
// should ALWAYS be a pending connection).
clientSocket = serverSocket->Accept(false);
if (clientSocket == NULL) {
statusTextControl->AppendText(_("Error: couldn't accept a new connection\n"));
return;
}
IPaddress peerAddr;
if ( !clientSocket->GetPeer(peerAddr) ) {
statusTextControl->AppendText(_("New connection from unknown client accepted.\n"));
}
else {
clientAddr = getAddr(peerAddr);
statusTextControl->AppendText(_(
"\n=====================================\n"
"New client connection from ")+ clientAddr + _(" accepted\n"));
}
// Subscribe to socket events
// wxSOCKET_INPUT_FLAG - received data
// wxSOCKET_LOST_FLAG - lost connection
clientSocket->SetEventHandler(*this, SOCKET_ID);
clientSocket->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
clientSocket->Notify(true);
setDeferredFail(false);
deferredOpen = true;
statusTimer = new wxTimer(this, SERVER_STATUSTIMER);
statusTimer->Start(pollIntervalSlow, wxTIMER_ONE_SHOT);
serverState = connected;
UpdateStatusBar();
}
开发者ID:Gibbon1,项目名称:usbdm-eclipse-makefiles-build,代码行数:60,代码来源:GdbServerWindow.cpp
示例20: OnSocketEvent
void PSocketServer::OnSocketEvent(wxSocketEvent &event)
{
wxCharBuffer buf(32*1024);
wxSocketBase *sock = event.GetSocket();
switch (event.GetSocketEvent()) {
case wxSOCKET_INPUT:
sock->Read(buf.data(), 32*1024);
sock->Write(buf, 32*1024);
text->AppendText(buf);
text->AppendText("\n");
// sock->Destroy();
break;
case wxSOCKET_LOST:
this->checkSocketStatus(sock);
wxLogMessage("socket lost!");
sock->Destroy();
break;
default:
break;
}
}
开发者ID:pizzaman,项目名称:clientlog,代码行数:22,代码来源:PSocketServer.cpp
注:本文中的wxSocketEvent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论