AndroMeta  2.0.0
Public Member Functions
Meta::MBroker Class Reference

A distributed object broker for distributing or obtaining objects across a TCP/IP network. More...

#include <MBroker.h>

Inheritance diagram for Meta::MBroker:
Meta::MBrokerBase

List of all members.

Public Member Functions

 MBroker (MProcTask *task, MAuth *auth)
virtual ~MBroker ()
mnode process (MObject *object, mnode n, bool block)
MProcTasktask ()
bool listen (int port)
bool isListening () const
MAuthauth ()
const MAuthauth () const
mstr distribute (MObject *object, const mstr &className, const mstr &objectName="")
bool revoke (MObject *object)
MObjectobtain (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)
mvarsession (MObject *object)

Detailed Description

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.


Constructor & Destructor Documentation

Meta::MBroker::MBroker ( MProcTask task,
MAuth auth 
)

Constructor.

Parameters:
taskThe task to use for internal concurrent network processing. For optimal performance the task must be configured with an adequate number of threads.
authThe authenticator, or null to bypass authentication.
virtual Meta::MBroker::~MBroker ( ) [virtual]

Destructor.


Member Function Documentation

Returns:
The MAuth that the broker was constructed with.
const MAuth* Meta::MBroker::auth ( ) const
Returns:
The MAuth that the broker was constructed with.
mstr Meta::MBroker::distribute ( MObject object,
const mstr className,
const mstr objectName = "" 
)

Distribute the specified object.

Parameters:
classNameThe class name of the object.
objectNameThe broker's name of this object that client's use when obtaining the object. If empty, a name will be assigned.
Returns:
The name of the object as distributed, or empty string in the case of failure.
Returns:
true if the broker is currently listening on a port.
bool Meta::MBroker::listen ( int  port)

Begin listening on the specified port.

Returns:
true on success.
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.

Parameters:
hostHostname/IP address of remote host.
portPort number of remote host.
objectNameThe name of the object to obtain as distributed by the remote MBroker.
userUser to authenticate as.
keyKey to authenticate with, see MEncoder::generateKey().
sessionOptional application-specific session data.
Returns:
On success, a pointer to the object obtained which must now be cast to the appropriate type. Null is returned in the event of failure.
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.

Parameters:
objectThe object that is being obtained.
Returns:
true in order to grant access to the object.
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.

Returns:
true on success.

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.

Returns:
The task that the broker was constructed with.

Implements Meta::MBrokerBase.


The documentation for this class was generated from the following file: