public class Session extends Object
The list of available services is contained in the ServiceDirectory
which runs on a Session acting as the entry point for other sessions to
connect to. Not all Sessions need to have a ServiceDirectory
, they
can also be connected to a Session that already has one. When a Session
exposes a service, other connected sessions can contact that service. When
Sessions connect to each other, they create an undirected graph.
This class allows registering and exposing a new QiService
or
retrieving one as an AnyObject
.
Modifier and Type | Class and Description |
---|---|
static interface |
Session.ConnectionListener |
Modifier | Constructor and Description |
---|---|
|
Session()
Create a qimessaging session.
|
protected |
Session(long session) |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(Session.ConnectionListener listener) |
Future<Void> |
close()
Close connection to Service Directory
|
Future<Void> |
connect(String serviceDirectoryAddress)
Try to connect to given address.
|
List<String> |
endpoints()
List of URL session endpoints.
The return list is not modifiable. |
protected void |
finalize()
Called by garbage collector Finalize is overriden to manually delete C++
data
|
boolean |
isConnected() |
void |
loadService(String name) |
void |
onDisconnected(String callback,
Object object)
Deprecated.
|
int |
registerService(String name,
AnyObject object)
Register service on Service Directory
|
void |
removeConnectionListener(Session.ConnectionListener listener) |
Future<AnyObject> |
service(String name)
Ask for remote service to Service Directory.
|
void |
setClientAuthenticator(ClientAuthenticator authenticator) |
void |
setClientAuthenticatorFactory(ClientAuthenticatorFactory factory) |
Future<Void> |
unregisterService(int idx)
Unregister service from Service Directory
|
Future<Void> |
waitForService(String serviceName)
Create future for wait a service is ready to use.
|
public Session()
protected Session(long session)
public boolean isConnected()
public Future<Void> connect(String serviceDirectoryAddress)
serviceDirectoryAddress
- Address to connect to.Exception
- on error.public Future<AnyObject> service(String name)
name
- Name of service.public Future<Void> close()
protected void finalize() throws Throwable
public int registerService(String name, AnyObject object)
name
- Name of new serviceobject
- Instance of servicepublic Future<Void> unregisterService(int idx)
idx
- is return by registerServiceregisterService(String, AnyObject)
@Deprecated public void onDisconnected(String callback, Object object)
public void addConnectionListener(Session.ConnectionListener listener)
public void removeConnectionListener(Session.ConnectionListener listener)
public void setClientAuthenticatorFactory(ClientAuthenticatorFactory factory)
public void setClientAuthenticator(ClientAuthenticator authenticator)
public void loadService(String name)
public List<String> endpoints()
Copyright © 2020. All rights reserved.