added wx/ipc.h and used/documented it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -75,7 +75,7 @@ MyClient *my_client;
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
// service name (DDE classes) or port number (TCP/IP based classes)
|
||||
wxString service = "4242";
|
||||
wxString service = IPC_SERVICE;
|
||||
|
||||
// ignored under DDE, host name in TCP/IP based classes
|
||||
wxString hostName = "localhost";
|
||||
@@ -91,7 +91,8 @@ bool MyApp::OnInit()
|
||||
// suppress the log messages from MakeConnection()
|
||||
{
|
||||
wxLogNull nolog;
|
||||
the_connection = (MyConnection *)my_client->MakeConnection(hostName, service, "IPC TEST");
|
||||
the_connection = (MyConnection *)
|
||||
my_client->MakeConnection(hostName, service, IPC_TOPIC);
|
||||
|
||||
while ( !the_connection )
|
||||
{
|
||||
@@ -107,7 +108,7 @@ bool MyApp::OnInit()
|
||||
}
|
||||
}
|
||||
|
||||
if (!the_connection->StartAdvise("Item"))
|
||||
if (!the_connection->StartAdvise(IPC_ADVISE_NAME))
|
||||
wxMessageBox("StartAdvise failed", "Client Demo Error");
|
||||
|
||||
// Create the main frame window
|
||||
|
@@ -9,34 +9,16 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Adjust this before compiling, to switch between real DDE and TCP/IP
|
||||
* implementations.
|
||||
*/
|
||||
// You may set this to 0 to prevent DDE from being used even under Windows
|
||||
//#define wxUSE_DDE_FOR_IPC 0
|
||||
|
||||
// If 1, use real DDE. If 0, use TCP/IP
|
||||
#include <wx/ipc.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define wxUSE_DDE_FOR_SAMPLE 0
|
||||
#else
|
||||
#define wxUSE_DDE_FOR_SAMPLE 0
|
||||
#endif
|
||||
// the default service name
|
||||
#define IPC_SERVICE "4242"
|
||||
|
||||
#if wxUSE_DDE_FOR_SAMPLE
|
||||
|
||||
#define wxConnection wxDDEConnection
|
||||
#define wxServer wxDDEServer
|
||||
#define wxClient wxDDEClient
|
||||
|
||||
#include <wx/dde.h>
|
||||
|
||||
#else
|
||||
|
||||
#define wxConnection wxTCPConnection
|
||||
#define wxServer wxTCPServer
|
||||
#define wxClient wxTCPClient
|
||||
|
||||
#include <wx/sckipc.h>
|
||||
|
||||
#endif
|
||||
// the IPC topic
|
||||
#define IPC_TOPIC "IPC TEST"
|
||||
|
||||
// the name of the item we're being advised about
|
||||
#define IPC_ADVISE_NAME "Item"
|
||||
|
@@ -74,7 +74,7 @@ bool MyApp::OnInit()
|
||||
(new MyFrame(NULL, "Server"))->Show(TRUE);
|
||||
|
||||
// service name (DDE classes) or port number (TCP/IP based classes)
|
||||
wxString service = "4242";
|
||||
wxString service = IPC_SERVICE;
|
||||
|
||||
if (argc > 1)
|
||||
service = argv[1];
|
||||
@@ -136,7 +136,7 @@ void MyFrame::OnListBoxClick(wxCommandEvent& WXUNUSED(event))
|
||||
wxString value = listBox->GetStringSelection();
|
||||
if (the_connection)
|
||||
{
|
||||
the_connection->Advise("Item", (wxChar *)value.c_str());
|
||||
the_connection->Advise(IPC_ADVISE_NAME, (wxChar *)value.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,10 +173,11 @@ void IPCDialogBox::OnQuit(wxCommandEvent& event)
|
||||
|
||||
wxConnectionBase *MyServer::OnAcceptConnection(const wxString& topic)
|
||||
{
|
||||
if (strcmp(topic, "STDIO") != 0 && strcmp(topic, "IPC TEST") == 0)
|
||||
if ( topic == IPC_TOPIC )
|
||||
return new MyConnection(ipc_buffer, WXSIZEOF(ipc_buffer));
|
||||
else
|
||||
return NULL;
|
||||
|
||||
// unknown topic
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user