com::pcbsys::nirvana::client::p2p::nServiceFactory Class Reference

A ServiceFactory is used to create both client and server services. More...

#include <nServiceFactory.h>

Inherits Observable.

Public Member Functions

void close ()
 Closes all currently openned services and disconnects from the Realm server. More...
 
nServiceconnectToService (nServiceInfo *pServiceInfo, long timeout=-1)
 Given an nServiceInfo object this constructs an nService object which can then be used to communicate with a remote service. More...
 
nServerServicecreateEventService (const std::string &name, const std::string &description, long accessMask=-1)
 Given a name and a description, this call constructs a new event service and advertises the new service on the realm. More...
 
nServerServicecreateStreamService (const std::string &name, const std::string &description, long accessMask=-1)
 Given a name and a description, this call constructs a new stream service and advertises the new service on the realm. More...
 
nServiceInfofindService (const std::string &serviceName)
 Locates the information about the specified service. More...
 
std::list< nServiceInfo * > * getAllServices ()
 Returns a list of all known services. More...
 
std::list< nServiceInfo * > * getAllServices (long timeout)
 Returns a list of all known services. More...
 
bool isConnected ()
 If the factory has a connection to the Realm Server or not. More...
 
 nServiceFactory (nSessionAttributes *pSessionAttrib, const std::string &username="")
 Contructs a P2P Service Factory instance on the realm specified by the session attributes. More...
 
 nServiceFactory (nSession *pSession)
 Construct a P2P Service Factory re-using an existing nSession object. More...
 

Detailed Description

A ServiceFactory is used to create both client and server services.

Constructor & Destructor Documentation

com::pcbsys::nirvana::client::p2p::nServiceFactory::nServiceFactory ( nSessionAttributes pSessionAttrib,
const std::string &  username = "" 
)

Contructs a P2P Service Factory instance on the realm specified by the session attributes.

Parameters
*pSessionAttribThe SessionAttributes that reference the desired Realm
usernameThe username to supply to the realm server
Exceptions
nBaseClientExceptionIf unable to communicate with the realm
com::pcbsys::nirvana::client::p2p::nServiceFactory::nServiceFactory ( nSession pSession)

Construct a P2P Service Factory re-using an existing nSession object.

Parameters
*pSessionthe session to re-use
Exceptions
nBaseClientExceptionthrown if there are any problems connecting to the services on the specific realm

Member Function Documentation

void com::pcbsys::nirvana::client::p2p::nServiceFactory::close ( )

Closes all currently openned services and disconnects from the Realm server.

This should be done as the last thing.

nService* com::pcbsys::nirvana::client::p2p::nServiceFactory::connectToService ( nServiceInfo pServiceInfo,
long  timeout = -1 
)

Given an nServiceInfo object this constructs an nService object which can then be used to communicate with a remote service.

Parameters
*pServiceInfoAn nServiceInfo that contains the information regarding the service to connect to
timeoutMaximum time in milliseconds to attempt to connect to the service
Returns
nService A Service object connected to the remote service
Exceptions
IOExceptionif unable to communicate with the remote service, see the message for further information
nBaseClientExceptionIf an exception occured locally, see the message for further information
nServerService* com::pcbsys::nirvana::client::p2p::nServiceFactory::createEventService ( const std::string &  name,
const std::string &  description,
long  accessMask = -1 
)

Given a name and a description, this call constructs a new event service and advertises the new service on the realm.

Parameters
nameName of the service to create
descriptionA String detailing what this service is
accessMaskthe default acl permissions for the service
Returns
Returns an nEventService
Exceptions
nBaseClientExceptionIf an exception occured locally, see the message for further information
See Also
nEventService
nServerService* com::pcbsys::nirvana::client::p2p::nServiceFactory::createStreamService ( const std::string &  name,
const std::string &  description,
long  accessMask = -1 
)

Given a name and a description, this call constructs a new stream service and advertises the new service on the realm.

Parameters
nameName of the service to create
descriptionA String detailing what this service is
accessMaskthe default acl permissions for the service
Returns
Returns an nStreamService
Exceptions
nBaseClientExceptionIf an exception occured locally, see the message for further information
See Also
nStreamService
nServiceInfo* com::pcbsys::nirvana::client::p2p::nServiceFactory::findService ( const std::string &  serviceName)

Locates the information about the specified service.

Parameters
serviceNameThe name of the service to find the nServiceInfo about
Returns
ServiceInfo*
See Also
nServiceInfo
Exceptions
nIllegalArgumentExceptionif the service name is null or illegal
std::list<nServiceInfo*>* com::pcbsys::nirvana::client::p2p::nServiceFactory::getAllServices ( )

Returns a list of all known services.

Returns
Returns a list of all the services.
std::list<nServiceInfo*>* com::pcbsys::nirvana::client::p2p::nServiceFactory::getAllServices ( long  timeout)

Returns a list of all known services.

Returns
Returns a list of all the services.
Parameters
timeoutTime to wait before first service arrives.
bool com::pcbsys::nirvana::client::p2p::nServiceFactory::isConnected ( )

If the factory has a connection to the Realm Server or not.

Returns
bool indicating the connection status