]>
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"
14 #define ID_START 10000
15 #define ID_DISCONNECT 10001
16 #define ID_ADVISE 10002
18 #define ID_SERVERNAME 10004
20 // Define a new application
24 class MyApp
: public wxApp
27 virtual bool OnInit();
29 MyFrame
*GetFrame() { return m_frame
; };
38 class MyFrame
: public wxFrame
41 MyFrame(wxFrame
*frame
, const wxString
& title
);
43 void OnExit(wxCommandEvent
& event
);
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
); }
54 wxTextCtrl
* GetLog() { return (wxTextCtrl
*) FindWindow( ID_LOG
); }
59 void OnStart( wxCommandEvent
&event
);
60 void OnServerName( wxCommandEvent
&event
);
61 void OnDisconnect( wxCommandEvent
&event
);
62 void OnAdvise( wxCommandEvent
&event
);
67 class MyConnection
: public MyConnectionBase
70 virtual bool OnExecute(const wxString
& topic
, const void *data
, size_t size
, wxIPCFormat format
);
71 virtual const void *OnRequest(const wxString
& topic
, const wxString
& item
, size_t *size
, wxIPCFormat format
);
72 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
73 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
);
74 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
);
75 virtual bool DoAdvise(const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
76 virtual bool OnDisconnect();
81 wxString m_sRequestDate
;
82 char m_achRequestBytes
[3];
85 class MyServer
: public wxServer
91 bool IsConnected() { return m_connection
!= NULL
; };
92 MyConnection
*GetConnection() { return m_connection
; };
94 bool CanAdvise() { return m_connection
!= NULL
&& !m_connection
->m_sAdvise
.IsEmpty(); };
95 wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
98 MyConnection
*m_connection
;