Packagecom.pcbsys.nirvana.client.p2p
Classpublic class nServiceFactory
InheritancenServiceFactory Inheritance Object

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



Public Methods
 MethodDefined By
  
nServiceFactory(session:nSession, connectedCB:Function)
Construct a P2P Service Factory re-using an existing nSession object
nServiceFactory
  
allServices():Array
Returns an array of nServiceInfo
nServiceFactory
  
close():void
Closes all currently opened services and disconnects from the realm.
nServiceFactory
  
connectToService(serviceInfo:nServiceInfo, listener:nEventListener, connectToServiceCB:Function, timeout:Number = -1):void
Connects to the given service defined in the nServiceInfo and will wait for the timeout specified for the remote service to respond
nServiceFactory
  
findService(serviceName:String):nServiceInfo
Locates the information about the specified service.
nServiceFactory
  
isConnected():Boolean
Returns whether the factory has a connection to the realm
nServiceFactory
Constructor Detail
nServiceFactory()Constructor
public function nServiceFactory(session:nSession, connectedCB:Function)

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

Parameters
session:nSession — the session to re-use
 
connectedCB:Function — The callback once the initialisation is completed, it will be passed a nServiceFactory when called
Method Detail
allServices()method
public function allServices():Array

Returns an array of nServiceInfo

Returns
Array — Array of nServiceInfo
close()method 
public function close():void

Closes all currently opened services and disconnects from the realm. This function is called as the last step of disconnect.

connectToService()method 
public function connectToService(serviceInfo:nServiceInfo, listener:nEventListener, connectToServiceCB:Function, timeout:Number = -1):void

Connects to the given service defined in the nServiceInfo and will wait for the timeout specified for the remote service to respond

Parameters
serviceInfo:nServiceInfo — An nServiceInfo that contains the information regarding the service to connect to
 
listener:nEventListener — an nEventListener to use for callback when a new message arrives
 
connectToServiceCB:Function — the callback that accepts as a argument a nService when it is connected to.
 
timeout:Number (default = -1) — A time in milliseconds to wait for the service to come on-line, -1 sets infinite timeout.


Throws
nIllegalArgumentError — if service info is null or timeout is less than -1.
findService()method 
public function findService(serviceName:String):nServiceInfo

Locates the information about the specified service.

Parameters
serviceName:String — The name of the service to find the nServiceInfo about

Returns
nServiceInfo — ServiceInfo

Throws
nIllegalArgumentError — if the service name is null or illegal

See also

isConnected()method 
public function isConnected():Boolean

Returns whether the factory has a connection to the realm

Returns
Boolean — true if connected to the realm