X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/70d26c3f4ffb24d50457d405c9595fd23f9e5b7c..686ca1b5d4867bca6c82a82078fd26291c6e6659:/samples/ipc/server.h diff --git a/samples/ipc/server.h b/samples/ipc/server.h index 81aa31697b..5eeaa8549a 100644 --- a/samples/ipc/server.h +++ b/samples/ipc/server.h @@ -9,62 +9,95 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +#define ID_START 10000 +#define ID_DISCONNECT 10001 +#define ID_ADVISE 10002 +#define ID_LOG 10003 +#define ID_SERVERNAME 10004 + // Define a new application -class MyApp: public wxApp +class MyServer; +class MyConnection; +class MyFrame; + +class MyApp : public wxApp { - public: - bool OnInit(); +public: + virtual bool OnInit(); + virtual int OnExit(); + MyFrame *GetFrame() { return m_frame; }; + +protected: + MyFrame *m_frame; }; DECLARE_APP(MyApp) // Define a new frame -class MyFrame: public wxFrame +class MyFrame : public wxFrame { - public: - wxPanel *panel; - - MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); +public: + MyFrame(wxFrame *frame, const wxString& title); - void OnCloseWindow(wxCloseEvent& event); void OnExit(wxCommandEvent& event); - void OnListBoxClick(wxCommandEvent& event); -DECLARE_EVENT_TABLE() -}; + void OnClose(wxCloseEvent& event); -class IPCDialogBox; -class MyConnection: public wxConnection -{ - public: - IPCDialogBox *dialog; + void Enable(); + void Disconnect(); + +protected: + wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); } + wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); } + wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); } + wxButton* GetAdvise() { return (wxButton*) FindWindow( ID_ADVISE ); } + wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); } - MyConnection(char *buf, int size); - ~MyConnection(); - bool OnExecute(const wxString& topic, char *data, int size, wxIPCFormat format); - char *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format); - bool OnPoke(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format); - bool OnStartAdvise(const wxString& topic, const wxString& item); + MyServer *m_server; + + void OnStart( wxCommandEvent &event ); + void OnServerName( wxCommandEvent &event ); + void OnDisconnect( wxCommandEvent &event ); + void OnAdvise( wxCommandEvent &event ); + + DECLARE_EVENT_TABLE() }; -class MyServer: public wxServer +class MyConnection : public wxConnection { public: - wxConnectionBase *OnAcceptConnection(const wxString& topic); + MyConnection(); + ~MyConnection(); + + virtual bool OnExecute(const wxString& topic, wxChar *data, int size, wxIPCFormat format); + virtual wxChar *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format); + virtual bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format); + virtual bool OnStartAdvise(const wxString& topic, const wxString& item); + virtual bool OnStopAdvise(const wxString& topic, const wxString& item); + virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); + virtual bool OnDisconnect(); +protected: + void Log(const wxString& command, const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format); +public: + wxString m_sAdvise; +protected: + wxString m_sRequestDate; + char m_achRequestBytes[3]; }; -class IPCDialogBox: public wxDialog +class MyServer: public wxServer { public: - MyConnection *connection; - IPCDialogBox(wxFrame *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, MyConnection *the_connection); - - void OnQuit(wxCommandEvent& event); + MyServer(); + ~MyServer(); + void Disconnect(); + bool IsConnected() { return m_connection != NULL; }; + MyConnection *GetConnection() { return m_connection; }; + void Advise(); + bool CanAdvise() { return m_connection != NULL && !m_connection->m_sAdvise.IsEmpty(); }; + wxConnectionBase *OnAcceptConnection(const wxString& topic); -DECLARE_EVENT_TABLE() +protected: + MyConnection *m_connection; }; -#define SERVER_QUIT wxID_EXIT -#define SERVER_LISTBOX 500 -#define SERVER_QUIT_BUTTON 501