]>
git.saurik.com Git - wxWidgets.git/blob - samples/ipc/server.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: DDE sample: server
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "connection.h"
22 // Define a new application
26 class MyApp
: public wxApp
29 virtual bool OnInit();
30 MyFrame
*GetFrame() { return m_frame
; }
39 class MyFrame
: public wxFrame
42 MyFrame(wxFrame
*frame
, const wxString
& title
);
44 void OnClose(wxCloseEvent
& event
);
50 wxButton
* GetStart() { return (wxButton
*) FindWindow( ID_START
); }
51 wxChoice
* GetServername() { return (wxChoice
*) FindWindow( ID_SERVERNAME
); }
52 wxButton
* GetDisconnect() { return (wxButton
*) FindWindow( ID_DISCONNECT
); }
53 wxButton
* GetAdvise() { return (wxButton
*) FindWindow( ID_ADVISE
); }
58 void OnStart( wxCommandEvent
&event
);
59 void OnServerName( wxCommandEvent
&event
);
60 void OnDisconnect( wxCommandEvent
&event
);
61 void OnAdvise( wxCommandEvent
&event
);
66 class MyConnection
: public MyConnectionBase
69 virtual bool OnExecute(const wxString
& topic
, const void *data
, size_t size
, wxIPCFormat format
);
70 virtual const void *OnRequest(const wxString
& topic
, const wxString
& item
, size_t *size
, wxIPCFormat format
);
71 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
72 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
);
73 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
);
74 virtual bool DoAdvise(const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
75 virtual bool OnDisconnect();
77 // topic for which we advise the client or empty if none
81 // the data returned by last OnRequest(): we keep it in this wxString to
82 // ensure that the pointer we return from OnRequest() stays valid
83 wxString m_requestData
;
86 class MyServer
: public wxServer
93 bool IsConnected() { return m_connection
!= NULL
; }
94 MyConnection
*GetConnection() { return m_connection
; }
97 bool CanAdvise() { return m_connection
&& !m_connection
->m_advise
.empty(); }
99 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
102 MyConnection
*m_connection
;