12.2.2. Client status event handler
After the control channel is established, the site checks the connected client against the set of parameters provided by the endpoint as well as those set by the administrator on the site. If the client is eligible, it installs on the site. Then, the site assigns it an online status, and it is ready to interact with services. Otherwise, based on the reason for ineligibility, the site assigns it a status from the ClientStatus enumeration. The whole process ends with a call to the following handler:
void onStatusChanged(ClientEndpointEvent e)
To get the updated client status, follow these steps. In the handler’s body, call the getEndpoint method on the ‘e’ parameter. It returns the endpoint, which is of type ClientEndpoint, that invoked the handler. Then call the endpoint’s getStatus method. It has the following signature:
public ClientStatus getStatus()
The example below demonstrates these steps:
public void onStatusChanged(ClientEndpointEvent e)
{
ClientEndpoint clientEndpoint = e.getEndpoint();
ClientStatus clientStatus = clientEndpoint.getStatus();
System.out.println(String.format("The client status: %s", clientStatus));
}
Let’s consider the status names from the ClientStatus enumeration and their interpretation.
public enum ClientStatus
{
Offline,
Online,
ServiceTypeConflict,
AccessDenied,
ServiceOwnerDisabled,
SiteDisabled,
CreatorDisabled
}
- Offline – the client is offline while the endpoint is not connected to the site;
- Online – the client is ready to communicate with services;
- ServiceTypeConflict – the Service Type and Contract Author provided by the client are different from those declared on the site;
- AccessDenied – the client does not have any access rights to the service, while the Guest is not allowed or is not supported by the service;
- ServiceOwnerDisabled – the service owner is disabled by the Softnet MS administrator;
- ServiceDisabled – the service is disabled by the owner;
- CreatorDisabled – the client’s creator is disabled by the Softnet MS administrator. The creator can be the Owner or one of their contacts.