use of com.hazelcast.client.impl.spi.EventHandler in project hazelcast by hazelcast.
the class ClientListenerServiceImpl method invoke.
protected void invoke(ClientListenerRegistration listenerRegistration, Connection connection) throws Exception {
// This method should only be called from registrationExecutor
assert (Thread.currentThread().getName().contains("eventRegistration"));
if (listenerRegistration.getConnectionRegistrations().containsKey(connection)) {
return;
}
ListenerMessageCodec codec = listenerRegistration.getCodec();
ClientMessage request = codec.encodeAddRequest(registersLocalOnly());
EventHandler handler = listenerRegistration.getHandler();
if (logger.isFinestEnabled()) {
logger.finest("Register attempt of " + listenerRegistration + " to " + connection);
}
handler.beforeListenerRegister(connection);
ClientInvocation invocation = new ClientInvocation(client, request, null, connection);
invocation.setEventHandler(handler);
ClientInvocationFuture future = invocation.invokeUrgent();
ClientMessage clientMessage;
try {
clientMessage = future.get();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e, Exception.class);
}
UUID serverRegistrationId = codec.decodeAddResponse(clientMessage);
if (logger.isFinestEnabled()) {
logger.finest("Registered " + listenerRegistration + " to " + connection);
}
handler.onListenerRegister(connection);
long correlationId = request.getCorrelationId();
ClientConnectionRegistration registration = new ClientConnectionRegistration(serverRegistrationId, correlationId);
listenerRegistration.getConnectionRegistrations().put(connection, registration);
}
use of com.hazelcast.client.impl.spi.EventHandler in project hazelcast by hazelcast.
the class ClientInvocationServiceImpl method registerInvocation.
// package-visible for tests
void registerInvocation(ClientInvocation clientInvocation, ClientConnection connection) {
ClientMessage clientMessage = clientInvocation.getClientMessage();
long correlationId = clientMessage.getCorrelationId();
invocations.put(correlationId, clientInvocation);
EventHandler handler = clientInvocation.getEventHandler();
if (handler != null) {
connection.addEventHandler(correlationId, handler);
}
}
Aggregations