]>
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 #define ID_START 10000
13 #define ID_DISCONNECT 10001
14 #define ID_ADVISE 10002
16 #define ID_SERVERNAME 10004
18 // Define a new application
23 class MyApp
: public wxApp
26 virtual bool OnInit();
28 MyFrame
*GetFrame() { return m_frame
; };
37 class MyFrame
: public wxFrame
40 MyFrame(wxFrame
*frame
, const wxString
& title
);
42 void OnExit(wxCommandEvent
& event
);
43 void OnClose(wxCloseEvent
& event
);
49 wxButton
* GetStart() { return (wxButton
*) FindWindow( ID_START
); }
50 wxChoice
* GetServername() { return (wxChoice
*) FindWindow( ID_SERVERNAME
); }
51 wxButton
* GetDisconnect() { return (wxButton
*) FindWindow( ID_DISCONNECT
); }
52 wxButton
* GetAdvise() { return (wxButton
*) FindWindow( ID_ADVISE
); }
53 wxTextCtrl
* GetLog() { return (wxTextCtrl
*) FindWindow( ID_LOG
); }
58 void OnStart( wxCommandEvent
&event
);
59 void OnServerName( wxCommandEvent
&event
);
60 void OnDisconnect( wxCommandEvent
&event
);
61 void OnAdvise( wxCommandEvent
&event
);
66 class MyConnection
: public wxConnection
72 virtual bool OnExecute(const wxString
& topic
, wxChar
*data
, int size
, wxIPCFormat format
);
73 virtual const wxChar
*OnRequest(const wxString
& topic
, const wxString
& item
, int *size
, wxIPCFormat format
);
74 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
, wxChar
*data
, int size
, wxIPCFormat format
);
75 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
);
76 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
);
77 virtual bool Advise(const wxString
& item
, const wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
78 virtual bool OnDisconnect();
80 void Log(const wxString
& command
, const wxString
& topic
, const wxString
& item
, const wxChar
*data
, int size
, wxIPCFormat format
);
84 wxString m_sRequestDate
;
85 char m_achRequestBytes
[3];
88 class MyServer
: public wxServer
94 bool IsConnected() { return m_connection
!= NULL
; };
95 MyConnection
*GetConnection() { return m_connection
; };
97 bool CanAdvise() { return m_connection
!= NULL
&& !m_connection
->m_sAdvise
.IsEmpty(); };
98 wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
101 MyConnection
*m_connection
;