- if (strcmp(topic, "STDIO") != 0 && strcmp(topic, "IPC TEST") == 0)
- return new MyConnection(ipc_buffer, WXSIZEOF(ipc_buffer));
- else
- return NULL;
+ wxLogMessage("OnAcceptConnection(\"%s\")", topic);
+
+ if ( topic == IPC_TOPIC )
+ {
+ m_connection = new MyConnection();
+ wxGetApp().GetFrame()->UpdateUI();
+ wxLogMessage("Connection accepted");
+ return m_connection;
+ }
+ //else: unknown topic
+
+ wxLogMessage("Unknown topic, connection refused");
+ return NULL;
+}
+
+void MyServer::Disconnect()
+{
+ if ( m_connection )
+ {
+ wxDELETE(m_connection);
+ wxGetApp().GetFrame()->UpdateUI();
+ wxLogMessage("Disconnected client");
+ }
+}
+
+void MyServer::Advise()
+{
+ if ( CanAdvise() )
+ {
+ const wxDateTime now = wxDateTime::Now();
+
+ m_connection->Advise(m_connection->m_advise, now.Format());
+
+ const wxString s = now.FormatTime() + " " + now.FormatDate();
+ m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN);
+
+#if wxUSE_DDE_FOR_IPC
+ wxLogMessage("DDE Advise type argument cannot be wxIPC_PRIVATE. "
+ "The client will receive it as wxIPC_TEXT, "
+ " and receive the correct no of bytes, "
+ "but not print a correct log entry.");
+#endif
+ char bytes[3] = { '1', '2', '3' };
+ m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE);
+ }