|
AndroMeta
2.0.0
|
A distributed object broker for distributing or obtaining objects across a TCP/IP network. More...
#include <MBroker.h>
Public Member Functions | |
| MBroker (MProcTask *task, MAuth *auth) | |
| virtual | ~MBroker () |
| mnode | process (MObject *object, mnode n, bool block) |
| MProcTask * | task () |
| bool | listen (int port) |
| bool | isListening () const |
| MAuth * | auth () |
| const MAuth * | auth () const |
| mstr | distribute (MObject *object, const mstr &className, const mstr &objectName="") |
| bool | revoke (MObject *object) |
| MObject * | obtain (const mstr &host, int port, const mstr &objectName, const mstr &user="", const mstr &key="", const mvar &session=0) |
| virtual bool | onObtain (MObject *object) |
| bool | release (MObject *object, bool disconnect=false) |
| mvar & | session (MObject *object) |
A distributed object broker for distributing or obtaining objects across a TCP/IP network.
In order for an object to be distributed or obtained remotely, it must derive from MObject and provide the appropriate constructor calling MObject(MBrokerBase* broker). The user must also supply an MFactory, implementing MFactory::create(MBrokerBase* broker). The MBroker internally manages the request/response mechanism. At the application-level, remote method invocation, distributed processing, and other handling is controlled by various calls in MObject such as: MObject::remoteProcess(), MObject::isRemote(), MObject::isDistributed(), MObject::isLocal(), MObject::session(), MObject::onClientClosed(), MObject::onServerClosed(), etc. Please refer to MObject or examples/chat for details.
| Meta::MBroker::MBroker | ( | MProcTask * | task, |
| MAuth * | auth | ||
| ) |
Constructor.
| task | The task to use for internal concurrent network processing. For optimal performance the task must be configured with an adequate number of threads. |
| auth | The authenticator, or null to bypass authentication. |
| virtual Meta::MBroker::~MBroker | ( | ) | [virtual] |
Destructor.
| MAuth* Meta::MBroker::auth | ( | ) |
| const MAuth* Meta::MBroker::auth | ( | ) | const |
| mstr Meta::MBroker::distribute | ( | MObject * | object, |
| const mstr & | className, | ||
| const mstr & | objectName = "" |
||
| ) |
Distribute the specified object.
| className | The class name of the object. |
| objectName | The broker's name of this object that client's use when obtaining the object. If empty, a name will be assigned. |
| bool Meta::MBroker::isListening | ( | ) | const |
| bool Meta::MBroker::listen | ( | int | port | ) |
Begin listening on the specified port.
| MObject* Meta::MBroker::obtain | ( | const mstr & | host, |
| int | port, | ||
| const mstr & | objectName, | ||
| const mstr & | user = "", |
||
| const mstr & | key = "", |
||
| const mvar & | session = 0 |
||
| ) |
Obtain an object from a remote MBroker.
| host | Hostname/IP address of remote host. |
| port | Port number of remote host. |
| objectName | The name of the object to obtain as distributed by the remote MBroker. |
| user | User to authenticate as. |
| key | Key to authenticate with, see MEncoder::generateKey(). |
| session | Optional application-specific session data. |
| virtual bool Meta::MBroker::onObtain | ( | MObject * | object | ) | [virtual] |
Called on the server-side when a remote client attempts to obtain the specified object (after authentication has succeeded). The default behavior is to return true.
| object | The object that is being obtained. |
| mnode Meta::MBroker::process | ( | MObject * | object, |
| mnode | n, | ||
| bool | block | ||
| ) | [virtual] |
Do not call directly.
Implements Meta::MBrokerBase.
| bool Meta::MBroker::release | ( | MObject * | object, |
| bool | disconnect = false |
||
| ) | [virtual] |
Called on the client-side to release the specified object. May be called internally when a disconnect occurs in which case disconnect is set to true. Usually this method is not called directly, MObject::release() is to be used instead.
Implements Meta::MBrokerBase.
| bool Meta::MBroker::revoke | ( | MObject * | object | ) |
Revoke/stop serving the specified object.
| mvar& Meta::MBroker::session | ( | MObject * | object | ) | [virtual] |
Called to get the session data. Should not be called directly, MObject::session() should be used instead.
Implements Meta::MBrokerBase.
| MProcTask* Meta::MBroker::task | ( | ) | [virtual] |
Implements Meta::MBrokerBase.
1.7.6.1