12.2. Implementing event handlers
Here you follow the same approach as when implementing service event handlers. If the handler has a parameter of type ClientEndpointEvent, the updated object that caused an event to be raised can only be retrieved from the endpoint. To get the endpoint, call getEndpoint on the handler’s parameter ‘e’. The method has the following signature:
public ClientEndpoint getEndpoint()
The return value is of type ClientEndpoint, which represents a multi-service endpoint. If the endpoint is supposed to be single-service, you can cast it to ClientSEndpoint after checking if it is single-service (see the chapter “Service Status Detection”). The type is convenient to interact with a single remote service.
Some of the handlers associated with Service Group have a parameter ‘e’ of type RemoteServiceEvent derived from ClientEndpointEvent. Along with a derived method getEndpoint, it has a field service of type RemoteService. This is a remote service that caused the event to be raised by the platform.
Let’s look at how to implement each of the event handlers declared by the ClientEventListener interface.