+ switch (msg)
+ {
+ case IPC_EXECUTE:
+ {
+ void *data;
+ size_t size;
+ wxIPCFormat format;
+
+ format = (wxIPCFormat)codeci->Read8();
+ size = codeci->Read32();
+
+ data = connection->GetBufferAtLeast( size );
+ wxASSERT_MSG(data != NULL,
+ "Buffer too small in wxTCPEventHandler::Client_OnRequest" );
+ sockstrm->Read(data, size);
+
+ connection->OnExecute (topic_name, data, size, format);
+
+ break;
+ }
+ case IPC_ADVISE:
+ {
+ item = codeci->ReadString();
+ wxIPCFormat format = (wxIPCFormat)codeci->Read8();
+ size_t size = codeci->Read32();
+ void *data = connection->GetBufferAtLeast( size );
+ wxASSERT_MSG(data != NULL,
+ "Buffer too small in wxTCPEventHandler::Client_OnRequest" );
+ sockstrm->Read(data, size);
+
+ connection->OnAdvise (topic_name, item, data, size, format);
+
+ break;
+ }
+ case IPC_ADVISE_START:
+ {
+ item = codeci->ReadString();
+
+ bool ok = connection->OnStartAdvise (topic_name, item);
+ if (ok)
+ codeco->Write8(IPC_ADVISE_START);
+ else
+ codeco->Write8(IPC_FAIL);
+
+ break;
+ }
+ case IPC_ADVISE_STOP:
+ {
+ item = codeci->ReadString();
+
+ bool ok = connection->OnStopAdvise (topic_name, item);
+ if (ok)
+ codeco->Write8(IPC_ADVISE_STOP);
+ else
+ codeco->Write8(IPC_FAIL);
+
+ break;
+ }
+ case IPC_POKE:
+ {
+ item = codeci->ReadString();
+ wxIPCFormat format = (wxIPCFormat)codeci->Read8();
+ size_t size = codeci->Read32();
+ void *data = connection->GetBufferAtLeast( size );
+ wxASSERT_MSG(data != NULL,
+ "Buffer too small in wxTCPEventHandler::Client_OnRequest" );
+ sockstrm->Read(data, size);
+
+ connection->OnPoke (topic_name, item, data, size, format);
+
+ break;
+ }
+ case IPC_REQUEST:
+ {
+ wxIPCFormat format;
+
+ item = codeci->ReadString();
+ format = (wxIPCFormat)codeci->Read8();
+
+ size_t user_size = wxNO_LEN;
+ const void *user_data = connection->OnRequest(topic_name,
+ item,
+ &user_size,
+ format);
+
+ if (user_data)
+ {
+ codeco->Write8(IPC_REQUEST_REPLY);
+
+ if (user_size == wxNO_LEN)
+ {
+ switch (format)
+ {
+ case wxIPC_TEXT:
+ case wxIPC_UTF8TEXT:
+ user_size = strlen((const char *)user_data) + 1; // includes final NUL
+ break;
+ case wxIPC_UNICODETEXT:
+ user_size = (wcslen((const wchar_t *)user_data) + 1) * sizeof(wchar_t); // includes final NUL
+ break;
+ default:
+ user_size = 0;
+ }
+ }
+
+ codeco->Write32(user_size);
+ sockstrm->Write(user_data, user_size);
+ }
+ else
+ codeco->Write8(IPC_FAIL);
+
+ break;
+ }
+ case IPC_DISCONNECT:
+ {
+ sock->Notify(false);
+ sock->Close();
+ connection->SetConnected(false);
+ connection->OnDisconnect();
+ break;
+ }
+ default:
+ codeco->Write8(IPC_FAIL);
+ break;