// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+#include "connection.h"
+
+#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 MyServer;
+class MyFrame;
+
class MyApp : public wxApp
{
public:
virtual bool OnInit();
virtual int OnExit();
+ MyFrame *GetFrame() { return m_frame; };
-private:
- MyServer *m_server;
+protected:
+ MyFrame *m_frame;
};
DECLARE_APP(MyApp)
public:
MyFrame(wxFrame *frame, const wxString& title);
- void OnListBoxClick(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
+ void OnClose(wxCloseEvent& event);
-private:
- wxPanel *panel;
+ void Enable();
+ void Disconnect();
- DECLARE_EVENT_TABLE()
-};
+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 ); }
-class IPCDialogBox;
-class MyConnection : public wxConnection
-{
-public:
- 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 );
-private:
- IPCDialogBox *dialog;
+ DECLARE_EVENT_TABLE()
};
-class MyServer: public wxServer
+class MyConnection : public MyConnectionBase
{
public:
- wxConnectionBase *OnAcceptConnection(const wxString& topic);
+ virtual bool OnExecute(const wxString& topic, const void *data, size_t size, wxIPCFormat format);
+ virtual const void *OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format);
+ virtual bool OnPoke(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
+ virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
+ virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
+ virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
+ virtual bool OnDisconnect();
+
+ wxString m_sAdvise;
+
+protected:
+ wxString m_sRequestDate;
+ char m_achRequestBytes[3];
};
-class IPCDialogBox: public wxDialog
+class MyServer: public wxServer
{
public:
- IPCDialogBox(wxWindow *parent,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- MyConnection *the_connection);
-
- void OnQuit(wxCommandEvent& event);
-
-private:
- MyConnection *m_connection;
+ 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_EXIT wxID_EXIT
-#define SERVER_LISTBOX 500
-#define SERVER_QUIT_BUTTON 501