Committed a couple of IPC changes I forgot to do

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2002-09-02 08:30:52 +00:00
parent a543e3ce7e
commit b814b81248
2 changed files with 26 additions and 15 deletions

View File

@ -6,7 +6,7 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DDE_H_
@ -49,8 +49,8 @@ class WXDLLEXPORT wxDDEConnection: public wxConnectionBase
{
DECLARE_DYNAMIC_CLASS(wxDDEConnection)
public:
wxDDEConnection(char *buffer, int size);
wxDDEConnection(void);
wxDDEConnection(char *buffer, int size); // use external buffer
wxDDEConnection(); // use internal buffer
~wxDDEConnection(void);
// Calls that CLIENT can make
@ -70,9 +70,7 @@ public:
virtual bool OnDisconnect(void);
public:
char* m_bufPtr;
wxString m_topicName;
int m_bufSize;
wxDDEServer* m_server;
wxDDEClient* m_client;

View File

@ -346,12 +346,18 @@ wxTCPConnection::wxTCPConnection () : wxConnectionBase()
m_codeco = NULL;
}
wxTCPConnection::wxTCPConnection(char * WXUNUSED(buffer), int WXUNUSED(size))
wxTCPConnection::wxTCPConnection(wxChar *buffer, int size)
: wxConnectionBase(buffer, size)
{
m_sock = NULL;
m_sockstrm = NULL;
m_codeci = NULL;
m_codeco = NULL;
}
wxTCPConnection::~wxTCPConnection ()
{
Disconnect();
wxDELETE(m_codeci);
wxDELETE(m_codeco);
wxDELETE(m_sockstrm);
@ -371,10 +377,13 @@ void wxTCPConnection::Compress(bool WXUNUSED(on))
// Calls that CLIENT can make.
bool wxTCPConnection::Disconnect ()
{
if ( !GetConnected() )
return TRUE;
// Send the the disconnect message to the peer.
m_codeco->Write8(IPC_DISCONNECT);
m_sock->Notify(FALSE);
m_sock->Close();
SetConnected(false);
return TRUE;
}
@ -415,10 +424,11 @@ char *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat for
else
{
size_t s;
char *data = NULL;
s = m_codeci->Read32();
data = new char[s];
wxChar *data = GetBufferAtLeast( s );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPConnection::Request") );
m_sockstrm->Read(data, s);
if (size)
@ -552,12 +562,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
data = connection->GetBufferAtLeast( size );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
sockstrm->Read(data, size);
connection->OnExecute (topic_name, data, size, format);
delete [] data;
break;
}
case IPC_ADVISE:
@ -569,12 +580,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
item = codeci->ReadString();
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
data = connection->GetBufferAtLeast( size );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
sockstrm->Read(data, size);
connection->OnAdvise (topic_name, item, data, size, format);
delete [] data;
break;
}
case IPC_ADVISE_START:
@ -610,13 +622,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
item = codeci->ReadString();
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new wxChar[size];
data = connection->GetBufferAtLeast( size );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
sockstrm->Read(data, size);
connection->OnPoke (topic_name, item, data, size, format);
delete [] data;
break;
}
case IPC_REQUEST:
@ -648,6 +660,7 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
{
sock->Notify(FALSE);
sock->Close();
connection->SetConnected(false);
connection->OnDisconnect();
break;
}