wxWidgets: wxConnection Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
wxConnection Class Reference
Class List by Category » Interprocess Communication

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-3.x86_64/src/wxWidgets-3.1.5/interface/wx/ipc.h>`

Inheritance diagram for wxConnection:
[legend]

## Detailed Description

A wxConnection object represents the connection between a client and a server.

It is created by making a connection using a wxClient object, or by the acceptance of a connection by a wxServer object.

The bulk of a DDE-like (Dynamic Data Exchange) conversation is controlled by calling members in a wxConnection object or by overriding its members. The actual DDE-based implementation using wxDDEConnection is available on Windows only, but a platform-independent, socket-based version of this API is available using wxTCPConnection, which has the same API.

An application should normally derive a new connection class from wxConnection, in order to override the communication event handlers to do something interesting.

##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

See also
  wxClient, wxServer, Interprocess Communication

## Public Member Functions
| wxConnection ()
| Constructs a connection object.
| wxConnection (void *buffer, size_t size)
bool | Advise (const wxString &item, const void *data, size_t size, wxIPCFormat format=wxIPC_PRIVATE)
| Called by the server application to advise the client of a change in the data associated with the given item.
bool | Advise (const wxString &item, const char *data)
bool | Advise (const wxString &item, const wchar_t *data)
bool | Advise (const wxString &item, const wxString data)
bool | Disconnect ()
| Called by the client or server application to disconnect from the other program; it causes the OnDisconnect() message to be sent to the corresponding connection object in the other program.
bool | Execute (const void *data, size_t size, wxIPCFormat format=wxIPC_PRIVATE)
| Called by the client application to execute a command on the server.
bool | Execute (const char *data)
bool | Execute (const wchar_t *data)
bool | Execute (const wxString data)
virtual bool | OnAdvise (const wxString &topic, const wxString &item, const void *data, size_t size, wxIPCFormat format)
| Message sent to the client application when the server notifies it of a change in the data associated with the given item, using Advise().
virtual bool | OnDisconnect ()
| Message sent to the client or server application when the other application notifies it to end the connection.
virtual bool | OnExec (const wxString &topic, const wxString &data)
| Message sent to the server application when the client notifies it to execute the given data, using Execute().
virtual bool | OnPoke (const wxString &topic, const wxString &item, const void *data, size_t size, wxIPCFormat format)
| Message sent to the server application when the client notifies it to accept the given data.
virtual const void * | OnRequest (const wxString &topic, const wxString &item, size_t *size, wxIPCFormat format)
| Message sent to the server application when the client calls Request().
virtual bool | OnStartAdvise (const wxString &topic, const wxString &item)
| Message sent to the server application by the client, when the client wishes to start an 'advise loop' for the given topic and item.
virtual bool | OnStopAdvise (const wxString &topic, const wxString &item)
| Message sent to the server application by the client, when the client wishes to stop an 'advise loop' for the given topic and item.
bool | Poke (const wxString &item, const void *data, size_t size, wxIPCFormat format=wxIPC_PRIVATE)
| Called by the client application to poke data into the server.
bool | Poke (const wxString &item, const char *data)
bool | Poke (const wxString &item, const wchar_t *data)
bool | Poke (const wxString &item, const wxString data)
const void * | Request (const wxString &item, size_t *size, wxIPCFormat format=wxIPC_TEXT)
| Called by the client application to request data from the server.
bool | StartAdvise (const wxString &item)
| Called by the client application to ask if an advise loop can be started with the server.
bool | StopAdvise (const wxString &item)
| Called by the client application to ask if an advise loop can be stopped.
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data.
| wxObject (const wxObject &other)
| Copy ctor.
virtual | ~wxObject ()
| Destructor.
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class.
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj.
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone.
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer.
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data.
void | UnShare ()
| This is the same of AllocExclusive() but this method is public.
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.

## Static Public Member Functions
static bool | IsTextFormat (wxIPCFormat format)
| Returns true if the format is one of the text formats.
static wxString | GetTextFromData (const void *data, size_t size, wxIPCFormat format)
| Returns the data in any of the text formats as string.

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object.
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Constructor & Destructor Documentation

## ◆ wxConnection() [1/2]

wxConnection::wxConnection | ( |  | ) |

Constructs a connection object.

If no user-defined connection object is to be derived from wxConnection, then the constructor should not be called directly, since the default connection object will be provided on requesting (or accepting) a connection.

However, if the user defines his or her own derived connection object, the wxServer::OnAcceptConnection and/or wxClient::OnMakeConnection members should be replaced by functions which construct the new connection object.

If the arguments of the wxConnection constructor are void then the wxConnection object manages its own connection buffer, allocating memory as needed. A programmer-supplied buffer cannot be increased if necessary, and the program will assert if it is not large enough.

The programmer-supplied buffer is included mainly for backwards compatibility.

## ◆ wxConnection() [2/2]

wxConnection::wxConnection | ( | void * | buffer,
|  | size_t | size )

## Member Function Documentation

## ◆ Advise() [1/4]

bool wxConnection::Advise | ( | const wxString & | item,
|  | const char * | data )

## ◆ Advise() [2/4]

bool wxConnection::Advise | ( | const wxString & | item,
|  | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format = wxIPC_PRIVATE )

Called by the server application to advise the client of a change in the data associated with the given item.

Causes the client connection's OnAdvise() member to be called.

Returns
  true if successful.

## ◆ Advise() [3/4]

bool wxConnection::Advise | ( | const wxString & | item,
|  | const wchar_t * | data )

## ◆ Advise() [4/4]

bool wxConnection::Advise | ( | const wxString & | item,
|  | const wxString | data )

## ◆ Disconnect()

bool wxConnection::Disconnect | ( |  | ) |

Called by the client or server application to disconnect from the other program; it causes the OnDisconnect() message to be sent to the corresponding connection object in the other program.

Returns true if successful or already disconnected. The application that calls Disconnect() must explicitly delete its side of the connection.

## ◆ Execute() [1/4]

bool wxConnection::Execute | ( | const char * | data | ) |

## ◆ Execute() [2/4]

bool wxConnection::Execute | ( | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format = wxIPC_PRIVATE )

Called by the client application to execute a command on the server.

Can also be used to transfer arbitrary data to the server (similar to Poke() in that respect). Causes the server connection's OnExec() member to be called. Returns true if successful.

## ◆ Execute() [3/4]

bool wxConnection::Execute | ( | const wchar_t * | data | ) |

## ◆ Execute() [4/4]

bool wxConnection::Execute | ( | const wxString | data | ) |

## ◆ GetTextFromData()

wxString wxConnection::GetTextFromData | ( | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format )
| static

Returns the data in any of the text formats as string.

Parameters

  data | The raw data pointer as used with any of the other methods of this class.
  size | The size of the data buffer pointed to by data.
  format | The format of the data. It must be a text one, i.e. such that IsTextFormat() returns true for it.

Returns
  The string representation of the data. If the format is not text, an assertion failure is triggered and empty string is returned.

## ◆ IsTextFormat()

bool wxConnection::IsTextFormat | ( | wxIPCFormat | format | ) |
| static

Returns true if the format is one of the text formats.

The text formats are wxIPC_TEXT, wxIPC_UNICODETEXT and wxIPC_UTF8TEXT.

## ◆ OnAdvise()

virtual bool wxConnection::OnAdvise | ( | const wxString & | topic,
|  | const wxString & | item,
|  | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format )
| virtual

Message sent to the client application when the server notifies it of a change in the data associated with the given item, using Advise().

## ◆ OnDisconnect()

virtual bool wxConnection::OnDisconnect | ( |  | ) |
| virtual

Message sent to the client or server application when the other application notifies it to end the connection.

The default behaviour is to delete the connection object and return true, so applications should generally override OnDisconnect() (finally calling the inherited method as well) so that they know the connection object is no longer available.

## ◆ OnExec()

virtual bool wxConnection::OnExec | ( | const wxString & | topic,
|  | const wxString & | data )
| virtual

Message sent to the server application when the client notifies it to execute the given data, using Execute().

Note that there is no item associated with this message.

## ◆ OnPoke()

virtual bool wxConnection::OnPoke | ( | const wxString & | topic,
|  | const wxString & | item,
|  | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format )
| virtual

Message sent to the server application when the client notifies it to accept the given data.

## ◆ OnRequest()

virtual const void * wxConnection::OnRequest | ( | const wxString & | topic,
|  | const wxString & | item,
|  | size_t * | size,
|  | wxIPCFormat | format )
| virtual

Message sent to the server application when the client calls Request().

The server's OnRequest() method should respond by returning a character string, or NULL to indicate no data, and setting *size.

The character string must of course persist after the call returns.

## ◆ OnStartAdvise()

virtual bool wxConnection::OnStartAdvise | ( | const wxString & | topic,
|  | const wxString & | item )
| virtual

Message sent to the server application by the client, when the client wishes to start an 'advise loop' for the given topic and item.

The server can refuse to participate by returning false.

## ◆ OnStopAdvise()

virtual bool wxConnection::OnStopAdvise | ( | const wxString & | topic,
|  | const wxString & | item )
| virtual

Message sent to the server application by the client, when the client wishes to stop an 'advise loop' for the given topic and item.

The server can refuse to stop the advise loop by returning false, although this doesn't have much meaning in practice.

## ◆ Poke() [1/4]

bool wxConnection::Poke | ( | const wxString & | item,
|  | const char * | data )

## ◆ Poke() [2/4]

bool wxConnection::Poke | ( | const wxString & | item,
|  | const void * | data,
|  | size_t | size,
|  | wxIPCFormat | format = wxIPC_PRIVATE )

Called by the client application to poke data into the server.

Can be used to transfer arbitrary data to the server. Causes the server connection's OnPoke() member to be called. If size is -1 the size is computed from the string length of data.

Returns true if successful.

## ◆ Poke() [3/4]

bool wxConnection::Poke | ( | const wxString & | item,
|  | const wchar_t * | data )

## ◆ Poke() [4/4]

bool wxConnection::Poke | ( | const wxString & | item,
|  | const wxString | data )

## ◆ Request()

const void * wxConnection::Request | ( | const wxString & | item,
|  | size_t * | size,
|  | wxIPCFormat | format = wxIPC_TEXT )

Called by the client application to request data from the server.

Causes the server connection's OnRequest() member to be called. Size may be NULL or a pointer to a variable to receive the size of the requested item.

Returns a character string (actually a pointer to the connection's buffer) if successful, NULL otherwise. This buffer does not need to be deleted.

## ◆ StartAdvise()

bool wxConnection::StartAdvise | ( | const wxString & | item | ) |

Called by the client application to ask if an advise loop can be started with the server.

Causes the server connection's OnStartAdvise() member to be called. Returns true if the server okays it, false otherwise.

## ◆ StopAdvise()

bool wxConnection::StopAdvise | ( | const wxString & | item | ) |

Called by the client application to ask if an advise loop can be stopped.

Causes the server connection's OnStopAdvise() member to be called. Returns true if the server okays it, false otherwise.