From b4a05689f0286ea83ac99920f1d394347db6266f Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 13 Oct 2017 19:41:00 +0200 Subject: [PATCH] sessionManager notify cleanup --- .../network/connection/ConnectionImpl.java | 8 ++++---- .../network/connection/ConnectionManager.java | 16 ++++++++-------- src/dorkbox/network/connection/EndPoint.java | 2 +- .../network/connection/ISessionManager.java | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/dorkbox/network/connection/ConnectionImpl.java b/src/dorkbox/network/connection/ConnectionImpl.java index 3586bb2b..91f1f9aa 100644 --- a/src/dorkbox/network/connection/ConnectionImpl.java +++ b/src/dorkbox/network/connection/ConnectionImpl.java @@ -365,7 +365,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn if (logger2.isTraceEnabled()) { logger2.trace("Sending LOCAL {}", message); } - this.sessionManager.notifyOnMessage(this, message); + this.sessionManager.onMessage(this, message); } /** @@ -511,7 +511,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn // } else if (event instanceof IdleStateEvent) { if (((IdleStateEvent) event).state() == IdleState.ALL_IDLE) { - this.sessionManager.notifyOnIdle(this); + this.sessionManager.onIdle(this); } } @@ -532,7 +532,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn // delay close until it's finished. this.messageInProgress.set(true); - this.sessionManager.notifyOnMessage(this, object); + this.sessionManager.onMessage(this, object); this.messageInProgress.set(false); @@ -594,7 +594,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn if (isTCP || channelClass == LocalChannel.class) { // this is because channelInactive can ONLY happen when netty shuts down the channel. // and connection.close() can be called by the user. - this.sessionManager.connectionDisconnected(this); + this.sessionManager.onDisconnected(this); // close TCP/UDP together! close(); diff --git a/src/dorkbox/network/connection/ConnectionManager.java b/src/dorkbox/network/connection/ConnectionManager.java index f56f3eda..bce1d50a 100644 --- a/src/dorkbox/network/connection/ConnectionManager.java +++ b/src/dorkbox/network/connection/ConnectionManager.java @@ -300,7 +300,7 @@ class ConnectionManager implements Listeners, ISessionMana */ @Override public final - void notifyOnMessage(final C connection, final Object message) { + void onMessage(final C connection, final Object message) { notifyOnMessage0(connection, message, false); } @@ -342,7 +342,7 @@ class ConnectionManager implements Listeners, ISessionMana */ @Override public final - void notifyOnIdle(final C connection) { + void onIdle(final C connection) { boolean foundListener = onIdleManager.notifyIdle(connection, shutdown); if (foundListener) { @@ -355,7 +355,7 @@ class ConnectionManager implements Listeners, ISessionMana final IdentityMap> localManagers = localManagersREF.get(this); ConnectionManager localManager = localManagers.get(connection); if (localManager != null) { - localManager.notifyOnIdle(connection); + localManager.onIdle(connection); } } @@ -367,7 +367,7 @@ class ConnectionManager implements Listeners, ISessionMana @SuppressWarnings("Duplicates") @Override public - void connectionConnected(final C connection) { + void onConnected(final C connection) { addConnection(connection); boolean foundListener = onConnectedManager.notifyConnected(connection, shutdown); @@ -382,7 +382,7 @@ class ConnectionManager implements Listeners, ISessionMana final IdentityMap> localManagers = localManagersREF.get(this); ConnectionManager localManager = localManagers.get(connection); if (localManager != null) { - localManager.connectionConnected(connection); + localManager.onConnected(connection); } } @@ -394,7 +394,7 @@ class ConnectionManager implements Listeners, ISessionMana @SuppressWarnings("Duplicates") @Override public - void connectionDisconnected(final C connection) { + void onDisconnected(final C connection) { boolean foundListener = onDisconnectedManager.notifyDisconnected(connection, shutdown); if (foundListener) { @@ -408,7 +408,7 @@ class ConnectionManager implements Listeners, ISessionMana final IdentityMap> localManagers = localManagersREF.get(this); ConnectionManager localManager = localManagers.get(connection); if (localManager != null) { - localManager.connectionDisconnected(connection); + localManager.onDisconnected(connection); // remove myself from the "global" listeners so we can have our memory cleaned up. removeListenerManager(connection); @@ -725,7 +725,7 @@ class ConnectionManager implements Listeners, ISessionMana c = current.getValue(); current = current.next(); - notifyOnMessage(c, message); + onMessage(c, message); } } diff --git a/src/dorkbox/network/connection/EndPoint.java b/src/dorkbox/network/connection/EndPoint.java index 7a9c6ecb..bb761bbe 100644 --- a/src/dorkbox/network/connection/EndPoint.java +++ b/src/dorkbox/network/connection/EndPoint.java @@ -506,7 +506,7 @@ class EndPoint { // prep the channel wrapper connection.prep(); - this.connectionManager.connectionConnected((C) connection); + this.connectionManager.onConnected((C) connection); } /** diff --git a/src/dorkbox/network/connection/ISessionManager.java b/src/dorkbox/network/connection/ISessionManager.java index 8e0f358e..3f5f6869 100644 --- a/src/dorkbox/network/connection/ISessionManager.java +++ b/src/dorkbox/network/connection/ISessionManager.java @@ -22,17 +22,17 @@ interface ISessionManager { /** * Called when a message is received */ - void notifyOnMessage(C connection, Object message); + void onMessage(C connection, Object message); /** * Called when the connection has been idle (read & write) for 2 seconds */ - void notifyOnIdle(C connection); + void onIdle(C connection); - void connectionConnected(C connection); + void onConnected(C connection); - void connectionDisconnected(C connection); + void onDisconnected(C connection); /** * Returns a non-modifiable list of active connections. This is extremely slow, and not recommended!