1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: DDE sample: server
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "connection.h"
21 // Define a new application
25 class MyApp
: public wxApp
28 virtual bool OnInit();
29 MyFrame
*GetFrame() { return m_frame
; }
38 class MyFrame
: public wxFrame
41 MyFrame(wxFrame
*frame
, const wxString
& title
);
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
); }
57 void OnStart( wxCommandEvent
&event
);
58 void OnServerName( wxCommandEvent
&event
);
59 void OnDisconnect( wxCommandEvent
&event
);
60 void OnAdvise( wxCommandEvent
&event
);
65 class MyConnection
: public MyConnectionBase
68 virtual bool OnExecute(const wxString
& topic
, const void *data
, size_t size
, wxIPCFormat format
);
69 virtual const void *OnRequest(const wxString
& topic
, const wxString
& item
, size_t *size
, wxIPCFormat format
);
70 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
71 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
);
72 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
);
73 virtual bool DoAdvise(const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
74 virtual bool OnDisconnect();
76 // topic for which we advise the client or empty if none
80 // the data returned by last OnRequest(): we keep it in this buffer to
81 // ensure that the pointer we return from OnRequest() stays valid
82 wxCharBuffer m_requestData
;
85 class MyServer
: public wxServer
92 bool IsConnected() { return m_connection
!= NULL
; }
93 MyConnection
*GetConnection() { return m_connection
; }
96 bool CanAdvise() { return m_connection
&& !m_connection
->m_advise
.empty(); }
98 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
101 MyConnection
*m_connection
;