ListenerBridge -> Listeners (plural). add/removeListener -> add/remove
This commit is contained in:
parent
f8a33377d6
commit
d0ffd01d5e
|
@ -83,7 +83,7 @@ interface Connection {
|
|||
/**
|
||||
* Expose methods to modify the connection listeners.
|
||||
*/
|
||||
ListenerBridge listeners();
|
||||
Listeners listeners();
|
||||
|
||||
/**
|
||||
* Closes the connection
|
||||
|
|
|
@ -66,7 +66,7 @@ import io.netty.util.concurrent.Promise;
|
|||
@SuppressWarnings("unused")
|
||||
@Sharable
|
||||
public
|
||||
class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConnection, Connection, ListenerBridge, ConnectionBridge {
|
||||
class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConnection, Connection, Listeners, ConnectionBridge {
|
||||
|
||||
private final org.slf4j.Logger logger;
|
||||
|
||||
|
@ -692,7 +692,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||
*/
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge listeners() {
|
||||
Listeners listeners() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -713,7 +713,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge add(Listener listener) {
|
||||
Listeners add(Listener listener) {
|
||||
if (this.endPoint instanceof EndPointServer) {
|
||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||
// meaning --
|
||||
|
@ -755,7 +755,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge remove(Listener listener) {
|
||||
Listeners remove(Listener listener) {
|
||||
if (this.endPoint instanceof EndPointServer) {
|
||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||
// meaning --
|
||||
|
@ -790,7 +790,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||
*/
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge removeAll() {
|
||||
Listeners removeAll() {
|
||||
if (this.endPoint instanceof EndPointServer) {
|
||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||
// meaning --
|
||||
|
@ -825,7 +825,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||
*/
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge removeAll(Class<?> classType) {
|
||||
Listeners removeAll(Class<?> classType) {
|
||||
if (this.endPoint instanceof EndPointServer) {
|
||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||
// meaning --
|
||||
|
|
|
@ -37,7 +37,7 @@ import dorkbox.util.collections.ConcurrentEntry;
|
|||
// .equals() compares the identity on purpose,this because we cannot create two separate objects that are somehow equal to each other.
|
||||
@SuppressWarnings("unchecked")
|
||||
public
|
||||
class ConnectionManager<C extends Connection> implements ListenerBridge, ISessionManager<C>, ConnectionPoint, ConnectionBridgeServer<C>,
|
||||
class ConnectionManager<C extends Connection> implements Listeners, ISessionManager<C>, ConnectionPoint, ConnectionBridgeServer<C>,
|
||||
ConnectionExceptSpecifiedBridgeServer<C> {
|
||||
/**
|
||||
* Specifies the load-factor for the IdentityMap used to manage keeping track of the number of connections + listeners
|
||||
|
@ -119,7 +119,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge add(final Listener listener) {
|
||||
Listeners add(final Listener listener) {
|
||||
if (listener == null) {
|
||||
throw new IllegalArgumentException("listener cannot be null.");
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge remove(final Listener listener) {
|
||||
Listeners remove(final Listener listener) {
|
||||
if (listener == null) {
|
||||
throw new IllegalArgumentException("listener cannot be null.");
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||
*/
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge removeAll() {
|
||||
Listeners removeAll() {
|
||||
onMessageReceivedManager.removeAll();
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
|
@ -268,7 +268,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||
*/
|
||||
@Override
|
||||
public final
|
||||
ListenerBridge removeAll(final Class<?> classType) {
|
||||
Listeners removeAll(final Class<?> classType) {
|
||||
if (classType == null) {
|
||||
throw new IllegalArgumentException("classType cannot be null.");
|
||||
}
|
||||
|
|
|
@ -513,7 +513,7 @@ class EndPoint<C extends Connection> {
|
|||
* Expose methods to modify the listeners (connect/disconnect/idle/receive events).
|
||||
*/
|
||||
public final
|
||||
ListenerBridge listeners() {
|
||||
Listeners listeners() {
|
||||
return this.connectionManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package dorkbox.network.connection;
|
|||
* There should always be just a SINGLE connection type for the client or server
|
||||
*/
|
||||
public
|
||||
interface ListenerBridge {
|
||||
interface Listeners {
|
||||
/**
|
||||
* Adds a listener to this connection/endpoint to be notified of
|
||||
* connect/disconnect/idle/receive(object) events.
|
||||
|
@ -38,7 +38,7 @@ interface ListenerBridge {
|
|||
* the connection is notified on that event (ie, admin type listeners)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
ListenerBridge add(Listener listener);
|
||||
Listeners add(Listener listener);
|
||||
|
||||
/**
|
||||
* Removes a listener from this connection/endpoint to NO LONGER be notified
|
||||
|
@ -53,19 +53,19 @@ interface ListenerBridge {
|
|||
* the connection is removed
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
ListenerBridge remove(Listener listener);
|
||||
Listeners remove(Listener listener);
|
||||
|
||||
/**
|
||||
* Removes all registered listeners from this connection/endpoint to NO
|
||||
* LONGER be notified of connect/disconnect/idle/receive(object) events.
|
||||
*/
|
||||
ListenerBridge removeAll();
|
||||
Listeners removeAll();
|
||||
|
||||
/**
|
||||
* Removes all registered listeners (of the object type) from this
|
||||
* connection/endpoint to NO LONGER be notified of
|
||||
* connect/disconnect/idle/receive(object) events.
|
||||
*/
|
||||
ListenerBridge removeAll(Class<?> classType);
|
||||
Listeners removeAll(Class<?> classType);
|
||||
|
||||
}
|
|
@ -23,19 +23,16 @@ interface Ping {
|
|||
int getResponse();
|
||||
|
||||
/**
|
||||
* Adds the specified listener to this future. The specified listener is
|
||||
* notified when this future is done. If this future is already completed,
|
||||
* the specified listener is notified immediately.
|
||||
* Adds a ping listener to this future. The listener is notified when this future is done. If this future is already completed,
|
||||
* then the listener is notified immediately.
|
||||
*/
|
||||
<C extends Connection> void addListener(PingListener<C> listener);
|
||||
<C extends Connection> void add(PingListener<C> listener);
|
||||
|
||||
/**
|
||||
* Removes the specified listener from this future. The specified listener
|
||||
* is no longer notified when this future is done. If the specified listener
|
||||
* is not associated with this future, this method does nothing and returns
|
||||
* silently.
|
||||
* Removes a ping listener from this future. The listener is no longer notified when this future is done. If the listener
|
||||
* was not previously associated with this future, this method does nothing and returns silently.
|
||||
*/
|
||||
<C extends Connection> void removeListener(PingListener<C> listener);
|
||||
<C extends Connection> void remove(PingListener<C> listener);
|
||||
|
||||
/**
|
||||
* Cancel this Ping.
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
*/
|
||||
package dorkbox.network.connection.ping;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.Ping;
|
||||
import dorkbox.network.connection.PingListener;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public
|
||||
class PingFuture implements Ping {
|
||||
|
||||
|
@ -78,7 +78,7 @@ class PingFuture implements Ping {
|
|||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public
|
||||
<C extends Connection> void addListener(PingListener<C> listener) {
|
||||
<C extends Connection> void add(PingListener<C> listener) {
|
||||
this.promise.addListener((GenericFutureListener) listener);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class PingFuture implements Ping {
|
|||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public
|
||||
<C extends Connection> void removeListener(PingListener<C> listener) {
|
||||
<C extends Connection> void remove(PingListener<C> listener) {
|
||||
this.promise.removeListener((GenericFutureListener) listener);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import dorkbox.network.connection.Connection;
|
|||
import dorkbox.network.connection.ConnectionImpl;
|
||||
import dorkbox.network.connection.EndPoint;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.network.rmi.RmiBridge;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
@ -116,7 +116,7 @@ class ListenerTest extends BaseTest {
|
|||
|
||||
addEndPoint(server);
|
||||
server.bind(false);
|
||||
final ListenerBridge listeners = server.listeners();
|
||||
final Listeners listeners = server.listeners();
|
||||
|
||||
// standard listener
|
||||
listeners.add(new Listener.OnMessageReceived<TestConnectionA, String>() {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.junit.Test;
|
|||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.CryptoSerializationManager;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
||||
|
@ -72,7 +72,7 @@ class MultipleThreadTest extends BaseTest {
|
|||
server.bind(false);
|
||||
|
||||
|
||||
final ListenerBridge listeners = server.listeners();
|
||||
final Listeners listeners = server.listeners();
|
||||
listeners.add(new Listener.OnConnected<Connection>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.Test;
|
|||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.CryptoSerializationManager;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.SerializationManager;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
@ -55,7 +55,7 @@ class PingPongLocalTest extends BaseTest {
|
|||
Server server = new Server(configuration);
|
||||
addEndPoint(server);
|
||||
server.bind(false);
|
||||
final ListenerBridge listeners = server.listeners();
|
||||
final Listeners listeners = server.listeners();
|
||||
listeners.add(new Listener.OnError<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
@ -81,7 +81,7 @@ class PingPongLocalTest extends BaseTest {
|
|||
|
||||
Client client = new Client();
|
||||
addEndPoint(client);
|
||||
final ListenerBridge listeners1 = client.listeners();
|
||||
final Listeners listeners1 = client.listeners();
|
||||
listeners1.add(new Listener.OnConnected<Connection>() {
|
||||
AtomicInteger check = new AtomicInteger(0);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import dorkbox.network.connection.Connection;
|
|||
import dorkbox.network.connection.CryptoSerializationManager;
|
||||
import dorkbox.network.connection.EndPoint;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.SerializationManager;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
@ -73,7 +73,7 @@ class PingPongTest extends BaseTest {
|
|||
Server server = new Server(configuration);
|
||||
addEndPoint(server);
|
||||
server.bind(false);
|
||||
final ListenerBridge listeners1 = server.listeners();
|
||||
final Listeners listeners1 = server.listeners();
|
||||
listeners1.add(new Listener.OnError<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
@ -113,7 +113,7 @@ class PingPongTest extends BaseTest {
|
|||
|
||||
Client client = new Client(configuration);
|
||||
addEndPoint(client);
|
||||
final ListenerBridge listeners = client.listeners();
|
||||
final Listeners listeners = client.listeners();
|
||||
listeners.add(new Listener.OnConnected<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
|
|
@ -100,7 +100,7 @@ class PingTest extends BaseTest {
|
|||
if (this.count++ < 10) {
|
||||
connection.send()
|
||||
.ping()
|
||||
.addListener(this);
|
||||
.add(this);
|
||||
}
|
||||
else {
|
||||
PingTest.this.response = pingResponseTime;
|
||||
|
@ -113,7 +113,7 @@ class PingTest extends BaseTest {
|
|||
// doesn't matter how many times this is called. If there is a PING waiting, then it's overwritten
|
||||
Ping ping = client.send()
|
||||
.ping();
|
||||
ping.addListener(pingListener);
|
||||
ping.add(pingListener);
|
||||
|
||||
waitForThreads();
|
||||
|
||||
|
@ -159,7 +159,7 @@ class PingTest extends BaseTest {
|
|||
// doesn't matter how many times this is called. If there is a PING waiting, then it's overwritten
|
||||
Ping ping = client.send()
|
||||
.ping();
|
||||
ping.addListener(pingListener);
|
||||
ping.add(pingListener);
|
||||
|
||||
waitForThreads();
|
||||
if (this.response == -1) {
|
||||
|
|
|
@ -19,17 +19,18 @@
|
|||
*/
|
||||
package dorkbox.network;
|
||||
|
||||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
||||
public
|
||||
class ReuseTest extends BaseTest {
|
||||
|
@ -49,7 +50,7 @@ class ReuseTest extends BaseTest {
|
|||
|
||||
Server server = new Server(configuration);
|
||||
addEndPoint(server);
|
||||
final ListenerBridge listeners = server.listeners();
|
||||
final Listeners listeners = server.listeners();
|
||||
listeners.add(new Listener.OnConnected<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
@ -73,7 +74,7 @@ class ReuseTest extends BaseTest {
|
|||
|
||||
Client client = new Client(configuration);
|
||||
addEndPoint(client);
|
||||
final ListenerBridge listeners1 = client.listeners();
|
||||
final Listeners listeners1 = client.listeners();
|
||||
listeners1.add(new Listener.OnConnected<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
|
|
@ -32,7 +32,7 @@ import dorkbox.network.connection.Connection;
|
|||
import dorkbox.network.connection.CryptoSerializationManager;
|
||||
import dorkbox.network.connection.EndPoint;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
||||
|
@ -105,7 +105,7 @@ class UnregisteredClassTest extends BaseTest {
|
|||
|
||||
Client client = new Client(configuration);
|
||||
addEndPoint(client);
|
||||
final ListenerBridge listeners = client.listeners();
|
||||
final Listeners listeners = client.listeners();
|
||||
listeners.add(new Listener.OnConnected<Connection>() {
|
||||
@Override
|
||||
public
|
||||
|
|
|
@ -50,7 +50,7 @@ import dorkbox.network.Server;
|
|||
import dorkbox.network.connection.Connection;
|
||||
import dorkbox.network.connection.CryptoSerializationManager;
|
||||
import dorkbox.network.connection.Listener;
|
||||
import dorkbox.network.connection.ListenerBridge;
|
||||
import dorkbox.network.connection.Listeners;
|
||||
import dorkbox.util.exceptions.InitializationException;
|
||||
import dorkbox.util.exceptions.SecurityException;
|
||||
|
||||
|
@ -200,7 +200,7 @@ class RmiTest extends BaseTest {
|
|||
addEndPoint(server);
|
||||
server.bind(false);
|
||||
|
||||
final ListenerBridge listeners = server.listeners();
|
||||
final Listeners listeners = server.listeners();
|
||||
listeners.add(new Listener.OnMessageReceived<Connection, MessageWithTestCow>() {
|
||||
@Override
|
||||
public
|
||||
|
|
Loading…
Reference in New Issue
Block a user