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:
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.


Member Function Documentation

const MAuth* Meta::MBroker::auth (  )  const
Returns:
The MAuth that the broker was constructed with.
MAuth* Meta::MBroker::auth (  ) 
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:
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.
Returns:
The name of the object as distributed, or empty string in the case of failure.
bool Meta::MBroker::isListening (  )  const
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:
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 MAuth::generateKey().
session Optional 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:
object The 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.

MProcTask* Meta::MBroker::task (  )  [virtual]
Returns:
The task that the broker was constructed with.

Implements Meta::MBrokerBase.


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

Generated on Wed Mar 24 16:22:42 2010 for AndroMeta by  doxygen 1.6.1