Skip to content

Commit

Permalink
Use classes in local connection handler registry.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuujo committed Jul 26, 2015
1 parent 5a401e7 commit f904b83
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -37,7 +37,7 @@ public class LocalConnection implements Connection {
private final Context context; private final Context context;
private final Set<LocalConnection> connections; private final Set<LocalConnection> connections;
private LocalConnection connection; private LocalConnection connection;
private final Map<String, HandlerHolder> handlers = new ConcurrentHashMap<>(); private final Map<Class, HandlerHolder> handlers = new ConcurrentHashMap<>();
private final Listeners<Throwable> exceptionListeners = new Listeners<>(); private final Listeners<Throwable> exceptionListeners = new Listeners<>();
private final Listeners<Connection> closeListeners = new Listeners<>(); private final Listeners<Connection> closeListeners = new Listeners<>();


Expand Down Expand Up @@ -94,7 +94,7 @@ public <T, U> CompletableFuture<U> send(T message) {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T, U> CompletableFuture<U> receive(T message) { private <T, U> CompletableFuture<U> receive(T message) {
HandlerHolder holder = handlers.get(message.getClass().getName()); HandlerHolder holder = handlers.get(message.getClass());
if (holder != null) { if (holder != null) {
MessageHandler<T, U> handler = holder.handler; MessageHandler<T, U> handler = holder.handler;
CompletableFuture<U> future = new CompletableFuture<>(); CompletableFuture<U> future = new CompletableFuture<>();
Expand All @@ -115,7 +115,7 @@ private <T, U> CompletableFuture<U> receive(T message) {
@Override @Override
public <T, U> Connection handler(Class<T> type, MessageHandler<T, U> handler) { public <T, U> Connection handler(Class<T> type, MessageHandler<T, U> handler) {
if (handler != null) { if (handler != null) {
handlers.put(type.getName(), new HandlerHolder(handler, getContext())); handlers.put(type, new HandlerHolder(handler, getContext()));
} else { } else {
handlers.remove(type); handlers.remove(type);
} }
Expand Down

0 comments on commit f904b83

Please sign in to comment.