Optimized event implementation to reduce memory footprint and improve performance somewhat
This commit is contained in:
parent
ebcf1b84e0
commit
8f92cfb80a
@ -171,7 +171,7 @@ public class Channels {
|
|||||||
* 'destination' when the event is sent downstream)
|
* 'destination' when the event is sent downstream)
|
||||||
*/
|
*/
|
||||||
public static MessageEvent messageEvent(Channel channel, ChannelFuture future, Object message, SocketAddress remoteAddress) {
|
public static MessageEvent messageEvent(Channel channel, ChannelFuture future, Object message, SocketAddress remoteAddress) {
|
||||||
return new DefaultMessageEvent(channel, future, message, remoteAddress);
|
return new DownstreamMessageEvent(channel, future, message, remoteAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// event emission methods
|
// event emission methods
|
||||||
@ -189,9 +189,8 @@ public class Channels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.OPEN, Boolean.TRUE));
|
||||||
ChannelState.OPEN, Boolean.TRUE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,9 +201,8 @@ public class Channels {
|
|||||||
* {@link #fireChannelOpen(Channel)} method.
|
* {@link #fireChannelOpen(Channel)} method.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelOpen(ChannelHandlerContext ctx) {
|
public static void fireChannelOpen(ChannelHandlerContext ctx) {
|
||||||
ctx.sendUpstream(new DefaultChannelStateEvent(
|
ctx.sendUpstream(new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.OPEN, Boolean.TRUE));
|
||||||
ChannelState.OPEN, Boolean.TRUE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,9 +231,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelBound(Channel channel, SocketAddress localAddress) {
|
public static void fireChannelBound(Channel channel, SocketAddress localAddress) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.BOUND, localAddress));
|
||||||
ChannelState.BOUND, localAddress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,9 +244,8 @@ public class Channels {
|
|||||||
* the local address where the specified channel is bound
|
* the local address where the specified channel is bound
|
||||||
*/
|
*/
|
||||||
public static void fireChannelBound(ChannelHandlerContext ctx, SocketAddress localAddress) {
|
public static void fireChannelBound(ChannelHandlerContext ctx, SocketAddress localAddress) {
|
||||||
ctx.sendUpstream(new DefaultChannelStateEvent(
|
ctx.sendUpstream(new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.BOUND, localAddress));
|
||||||
ChannelState.BOUND, localAddress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,9 +276,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelConnected(Channel channel, SocketAddress remoteAddress) {
|
public static void fireChannelConnected(Channel channel, SocketAddress remoteAddress) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.CONNECTED, remoteAddress));
|
||||||
ChannelState.CONNECTED, remoteAddress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,9 +290,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelConnected(ChannelHandlerContext ctx, SocketAddress remoteAddress) {
|
public static void fireChannelConnected(ChannelHandlerContext ctx, SocketAddress remoteAddress) {
|
||||||
|
|
||||||
ctx.sendUpstream(new DefaultChannelStateEvent(
|
ctx.sendUpstream(new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.CONNECTED, remoteAddress));
|
||||||
ChannelState.CONNECTED, remoteAddress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -340,9 +334,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireMessageReceived(Channel channel, Object message, SocketAddress remoteAddress) {
|
public static void fireMessageReceived(Channel channel, Object message, SocketAddress remoteAddress) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultMessageEvent(
|
new UpstreamMessageEvent(channel, message, remoteAddress));
|
||||||
channel, succeededFuture(channel),
|
|
||||||
message, remoteAddress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,8 +345,7 @@ public class Channels {
|
|||||||
* @param message the received message
|
* @param message the received message
|
||||||
*/
|
*/
|
||||||
public static void fireMessageReceived(ChannelHandlerContext ctx, Object message) {
|
public static void fireMessageReceived(ChannelHandlerContext ctx, Object message) {
|
||||||
ctx.sendUpstream(new DefaultMessageEvent(
|
ctx.sendUpstream(new UpstreamMessageEvent(ctx.getChannel(), message, null));
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()), message, null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,8 +376,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireMessageReceived(
|
public static void fireMessageReceived(
|
||||||
ChannelHandlerContext ctx, Object message, SocketAddress remoteAddress) {
|
ChannelHandlerContext ctx, Object message, SocketAddress remoteAddress) {
|
||||||
ctx.sendUpstream(new DefaultMessageEvent(
|
ctx.sendUpstream(new UpstreamMessageEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()), message, remoteAddress));
|
ctx.getChannel(), message, remoteAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,8 +410,7 @@ public class Channels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultWriteCompletionEvent(
|
new DefaultWriteCompletionEvent(channel, amount));
|
||||||
channel, succeededFuture(channel), amount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,8 +419,7 @@ public class Channels {
|
|||||||
* the specified {@link ChannelHandlerContext} belongs.
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*/
|
*/
|
||||||
public static void fireWriteCompleted(ChannelHandlerContext ctx, int amount) {
|
public static void fireWriteCompleted(ChannelHandlerContext ctx, int amount) {
|
||||||
ctx.sendUpstream(new DefaultWriteCompletionEvent(
|
ctx.sendUpstream(new DefaultWriteCompletionEvent(ctx.getChannel(), amount));
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()), amount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,9 +429,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelInterestChanged(Channel channel) {
|
public static void fireChannelInterestChanged(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.INTEREST_OPS, Channel.OP_READ));
|
||||||
ChannelState.INTEREST_OPS, Channel.OP_READ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,9 +457,8 @@ public class Channels {
|
|||||||
ChannelHandlerContext ctx) {
|
ChannelHandlerContext ctx) {
|
||||||
|
|
||||||
ctx.sendUpstream(
|
ctx.sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.INTEREST_OPS, Channel.OP_READ));
|
||||||
ChannelState.INTEREST_OPS, Channel.OP_READ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,9 +486,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelDisconnected(Channel channel) {
|
public static void fireChannelDisconnected(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.CONNECTED, null));
|
||||||
ChannelState.CONNECTED, null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,9 +496,8 @@ public class Channels {
|
|||||||
* the specified {@link ChannelHandlerContext} belongs.
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelDisconnected(ChannelHandlerContext ctx) {
|
public static void fireChannelDisconnected(ChannelHandlerContext ctx) {
|
||||||
ctx.sendUpstream(new DefaultChannelStateEvent(
|
ctx.sendUpstream(new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.CONNECTED, null));
|
||||||
ChannelState.CONNECTED, null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -535,8 +520,8 @@ public class Channels {
|
|||||||
* the specified {@link Channel}.
|
* the specified {@link Channel}.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelUnbound(Channel channel) {
|
public static void fireChannelUnbound(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendUpstream(new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel), ChannelState.BOUND, null));
|
channel, ChannelState.BOUND, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -546,8 +531,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelUnbound(ChannelHandlerContext ctx) {
|
public static void fireChannelUnbound(ChannelHandlerContext ctx) {
|
||||||
|
|
||||||
ctx.sendUpstream(new DefaultChannelStateEvent(
|
ctx.sendUpstream(new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()), ChannelState.BOUND, null));
|
ctx.getChannel(), ChannelState.BOUND, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -571,9 +556,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelClosed(Channel channel) {
|
public static void fireChannelClosed(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
channel, succeededFuture(channel),
|
channel, ChannelState.OPEN, Boolean.FALSE));
|
||||||
ChannelState.OPEN, Boolean.FALSE));
|
|
||||||
|
|
||||||
// Notify the parent handler.
|
// Notify the parent handler.
|
||||||
if (channel.getParent() != null) {
|
if (channel.getParent() != null) {
|
||||||
@ -588,9 +572,8 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireChannelClosed(ChannelHandlerContext ctx) {
|
public static void fireChannelClosed(ChannelHandlerContext ctx) {
|
||||||
ctx.sendUpstream(
|
ctx.sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new UpstreamChannelStateEvent(
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()),
|
ctx.getChannel(), ChannelState.OPEN, Boolean.FALSE));
|
||||||
ChannelState.OPEN, Boolean.FALSE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -614,8 +597,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void fireExceptionCaught(Channel channel, Throwable cause) {
|
public static void fireExceptionCaught(Channel channel, Throwable cause) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultExceptionEvent(
|
new DefaultExceptionEvent(channel, cause));
|
||||||
channel, succeededFuture(channel), cause));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -624,8 +606,7 @@ public class Channels {
|
|||||||
* the specified {@link ChannelHandlerContext} belongs.
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*/
|
*/
|
||||||
public static void fireExceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
public static void fireExceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||||
ctx.sendUpstream(new DefaultExceptionEvent(
|
ctx.sendUpstream(new DefaultExceptionEvent(ctx.getChannel(), cause));
|
||||||
ctx.getChannel(), succeededFuture(ctx.getChannel()), cause));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -646,8 +627,7 @@ public class Channels {
|
|||||||
private static void fireChildChannelStateChanged(
|
private static void fireChildChannelStateChanged(
|
||||||
Channel channel, Channel childChannel) {
|
Channel channel, Channel childChannel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChildChannelStateEvent(
|
new DefaultChildChannelStateEvent(channel, childChannel));
|
||||||
channel, succeededFuture(channel), childChannel));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,7 +646,7 @@ public class Channels {
|
|||||||
throw new NullPointerException("localAddress");
|
throw new NullPointerException("localAddress");
|
||||||
}
|
}
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.BOUND, localAddress));
|
channel, future, ChannelState.BOUND, localAddress));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -686,7 +666,7 @@ public class Channels {
|
|||||||
if (localAddress == null) {
|
if (localAddress == null) {
|
||||||
throw new NullPointerException("localAddress");
|
throw new NullPointerException("localAddress");
|
||||||
}
|
}
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.BOUND, localAddress));
|
ctx.getChannel(), future, ChannelState.BOUND, localAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +701,7 @@ public class Channels {
|
|||||||
* operation is done
|
* operation is done
|
||||||
*/
|
*/
|
||||||
public static void unbind(ChannelHandlerContext ctx, ChannelFuture future) {
|
public static void unbind(ChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.BOUND, null));
|
ctx.getChannel(), future, ChannelState.BOUND, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,7 +737,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static ChannelFuture unbind(Channel channel) {
|
public static ChannelFuture unbind(Channel channel) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.BOUND, null));
|
channel, future, ChannelState.BOUND, null));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -778,7 +758,7 @@ public class Channels {
|
|||||||
throw new NullPointerException("remoteAddress");
|
throw new NullPointerException("remoteAddress");
|
||||||
}
|
}
|
||||||
ChannelFuture future = future(channel, true);
|
ChannelFuture future = future(channel, true);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.CONNECTED, remoteAddress));
|
channel, future, ChannelState.CONNECTED, remoteAddress));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -798,7 +778,7 @@ public class Channels {
|
|||||||
if (remoteAddress == null) {
|
if (remoteAddress == null) {
|
||||||
throw new NullPointerException("remoteAddress");
|
throw new NullPointerException("remoteAddress");
|
||||||
}
|
}
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.CONNECTED, remoteAddress));
|
ctx.getChannel(), future, ChannelState.CONNECTED, remoteAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,7 +868,7 @@ public class Channels {
|
|||||||
public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) {
|
public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(
|
channel.getPipeline().sendDownstream(
|
||||||
new DefaultMessageEvent(channel, future, message, remoteAddress));
|
new DownstreamMessageEvent(channel, future, message, remoteAddress));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +888,7 @@ public class Channels {
|
|||||||
ChannelHandlerContext ctx, ChannelFuture future,
|
ChannelHandlerContext ctx, ChannelFuture future,
|
||||||
Object message, SocketAddress remoteAddress) {
|
Object message, SocketAddress remoteAddress) {
|
||||||
ctx.sendDownstream(
|
ctx.sendDownstream(
|
||||||
new DefaultMessageEvent(ctx.getChannel(), future, message, remoteAddress));
|
new DownstreamMessageEvent(ctx.getChannel(), future, message, remoteAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -950,7 +930,7 @@ public class Channels {
|
|||||||
interestOps = filterDownstreamInterestOps(interestOps);
|
interestOps = filterDownstreamInterestOps(interestOps);
|
||||||
|
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.INTEREST_OPS, Integer.valueOf(interestOps)));
|
channel, future, ChannelState.INTEREST_OPS, Integer.valueOf(interestOps)));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -970,7 +950,7 @@ public class Channels {
|
|||||||
interestOps = filterDownstreamInterestOps(interestOps);
|
interestOps = filterDownstreamInterestOps(interestOps);
|
||||||
|
|
||||||
ctx.sendDownstream(
|
ctx.sendDownstream(
|
||||||
new DefaultChannelStateEvent(
|
new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.INTEREST_OPS,
|
ctx.getChannel(), future, ChannelState.INTEREST_OPS,
|
||||||
Integer.valueOf(interestOps)));
|
Integer.valueOf(interestOps)));
|
||||||
}
|
}
|
||||||
@ -1006,7 +986,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static ChannelFuture disconnect(Channel channel) {
|
public static ChannelFuture disconnect(Channel channel) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.CONNECTED, null));
|
channel, future, ChannelState.CONNECTED, null));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -1021,7 +1001,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void disconnect(
|
public static void disconnect(
|
||||||
ChannelHandlerContext ctx, ChannelFuture future) {
|
ChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.CONNECTED, null));
|
ctx.getChannel(), future, ChannelState.CONNECTED, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1054,7 +1034,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static ChannelFuture close(Channel channel) {
|
public static ChannelFuture close(Channel channel) {
|
||||||
ChannelFuture future = channel.getCloseFuture();
|
ChannelFuture future = channel.getCloseFuture();
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
|
||||||
channel, future, ChannelState.OPEN, Boolean.FALSE));
|
channel, future, ChannelState.OPEN, Boolean.FALSE));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -1069,7 +1049,7 @@ public class Channels {
|
|||||||
*/
|
*/
|
||||||
public static void close(
|
public static void close(
|
||||||
ChannelHandlerContext ctx, ChannelFuture future) {
|
ChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DownstreamChannelStateEvent(
|
||||||
ctx.getChannel(), future, ChannelState.OPEN, Boolean.FALSE));
|
ctx.getChannel(), future, ChannelState.OPEN, Boolean.FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.channel;
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
import static org.jboss.netty.channel.Channels.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link ChildChannelStateEvent} implementation.
|
* The default {@link ChildChannelStateEvent} implementation.
|
||||||
*
|
*
|
||||||
@ -31,37 +33,46 @@ package org.jboss.netty.channel;
|
|||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultChildChannelStateEvent extends DefaultChannelEvent implements
|
public final class DefaultChildChannelStateEvent implements ChildChannelStateEvent {
|
||||||
ChildChannelStateEvent {
|
|
||||||
|
|
||||||
|
private final Channel parentChannel;
|
||||||
private final Channel childChannel;
|
private final Channel childChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultChildChannelStateEvent(
|
public DefaultChildChannelStateEvent(Channel parentChannel, Channel childChannel) {
|
||||||
Channel channel, ChannelFuture future, Channel childChannel) {
|
if (parentChannel == null) {
|
||||||
|
throw new NullPointerException("parentChannel");
|
||||||
super(channel, future);
|
}
|
||||||
if (childChannel == null) {
|
if (childChannel == null) {
|
||||||
throw new NullPointerException("childChannel");
|
throw new NullPointerException("childChannel");
|
||||||
}
|
}
|
||||||
|
this.parentChannel = parentChannel;
|
||||||
this.childChannel = childChannel;
|
this.childChannel = childChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return parentChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return succeededFuture(getChannel());
|
||||||
|
}
|
||||||
|
|
||||||
public Channel getChildChannel() {
|
public Channel getChildChannel() {
|
||||||
return childChannel;
|
return childChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String parentString = super.toString();
|
String channelString = getChannel().toString();
|
||||||
StringBuilder buf = new StringBuilder(parentString.length() + 32);
|
StringBuilder buf = new StringBuilder(channelString.length() + 32);
|
||||||
buf.append(parentString);
|
buf.append(channelString);
|
||||||
buf.append(" - (childId: ");
|
buf.append(" - (childId: ");
|
||||||
buf.append(getChildChannel().getId().toString());
|
buf.append(getChildChannel().getId().toString());
|
||||||
buf.append(", childState: ");
|
buf.append(", childState: ");
|
||||||
buf.append(getChildChannel().isOpen()? "OPEN" : "CLOSE");
|
buf.append(getChildChannel().isOpen()? "OPEN" : "CLOSED");
|
||||||
buf.append(')');
|
buf.append(')');
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.channel;
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
import static org.jboss.netty.channel.Channels.*;
|
||||||
|
|
||||||
import org.jboss.netty.util.StackTraceSimplifier;
|
import org.jboss.netty.util.StackTraceSimplifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,29 +35,40 @@ import org.jboss.netty.util.StackTraceSimplifier;
|
|||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultExceptionEvent extends DefaultChannelEvent implements
|
public final class DefaultExceptionEvent implements ExceptionEvent {
|
||||||
ExceptionEvent {
|
|
||||||
|
|
||||||
|
private final Channel channel;
|
||||||
private final Throwable cause;
|
private final Throwable cause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultExceptionEvent(Channel channel, ChannelFuture future, Throwable cause) {
|
public DefaultExceptionEvent(Channel channel, Throwable cause) {
|
||||||
super(channel, future);
|
if (channel == null) {
|
||||||
|
throw new NullPointerException("channel");
|
||||||
|
}
|
||||||
if (cause == null) {
|
if (cause == null) {
|
||||||
throw new NullPointerException("cause");
|
throw new NullPointerException("cause");
|
||||||
}
|
}
|
||||||
|
this.channel = channel;
|
||||||
this.cause = cause;
|
this.cause = cause;
|
||||||
StackTraceSimplifier.simplify(cause);
|
StackTraceSimplifier.simplify(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return succeededFuture(getChannel());
|
||||||
|
}
|
||||||
|
|
||||||
public Throwable getCause() {
|
public Throwable getCause() {
|
||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " - (cause: " + cause.getClass().getSimpleName() + ')';
|
return getChannel().toString() + " - (cause: " + cause.getClass().getSimpleName() + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.channel;
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
import static org.jboss.netty.channel.Channels.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link WriteCompletionEvent} implementation.
|
* The default {@link WriteCompletionEvent} implementation.
|
||||||
*
|
*
|
||||||
@ -30,26 +32,35 @@ package org.jboss.netty.channel;
|
|||||||
*
|
*
|
||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*/
|
*/
|
||||||
public class DefaultWriteCompletionEvent extends DefaultChannelEvent implements
|
public final class DefaultWriteCompletionEvent implements WriteCompletionEvent {
|
||||||
WriteCompletionEvent {
|
|
||||||
|
|
||||||
|
private final Channel channel;
|
||||||
private final int writtenAmount;
|
private final int writtenAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultWriteCompletionEvent(
|
public DefaultWriteCompletionEvent(Channel channel, int writtenAmount) {
|
||||||
Channel channel, ChannelFuture future, int writtenAmount) {
|
if (channel == null) {
|
||||||
|
throw new NullPointerException("channel");
|
||||||
super(channel, future);
|
}
|
||||||
if (writtenAmount <= 0) {
|
if (writtenAmount <= 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"writtenAmount must be a positive integer: " + writtenAmount);
|
"writtenAmount must be a positive integer: " + writtenAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.channel = channel;
|
||||||
this.writtenAmount = writtenAmount;
|
this.writtenAmount = writtenAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return succeededFuture(getChannel());
|
||||||
|
}
|
||||||
|
|
||||||
public int getWrittenAmount() {
|
public int getWrittenAmount() {
|
||||||
return writtenAmount;
|
return writtenAmount;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* JBoss, Home of Professional Open Source
|
||||||
|
*
|
||||||
|
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
|
||||||
|
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
|
||||||
|
* full listing of individual contributors.
|
||||||
|
*
|
||||||
|
* This is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2.1 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this software; if not, write to the Free
|
||||||
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||||
|
*/
|
||||||
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default {@link ChannelStateEvent} implementation.
|
||||||
|
*
|
||||||
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||||
|
* @author Trustin Lee (tlee@redhat.com)
|
||||||
|
*
|
||||||
|
* @version $Rev$, $Date$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class DownstreamChannelStateEvent implements ChannelStateEvent {
|
||||||
|
|
||||||
|
private final Channel channel;
|
||||||
|
private final ChannelFuture future;
|
||||||
|
private final ChannelState state;
|
||||||
|
private final Object value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*/
|
||||||
|
public DownstreamChannelStateEvent(
|
||||||
|
Channel channel, ChannelFuture future,
|
||||||
|
ChannelState state, Object value) {
|
||||||
|
|
||||||
|
if (channel == null) {
|
||||||
|
throw new NullPointerException("channel");
|
||||||
|
}
|
||||||
|
if (future == null) {
|
||||||
|
throw new NullPointerException("future");
|
||||||
|
}
|
||||||
|
if (state == null) {
|
||||||
|
throw new NullPointerException("state");
|
||||||
|
}
|
||||||
|
this.channel = channel;
|
||||||
|
this.future = future;
|
||||||
|
this.state = state;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String channelString = getChannel().toString();
|
||||||
|
StringBuilder buf = new StringBuilder(channelString.length() + 64);
|
||||||
|
buf.append(channelString);
|
||||||
|
buf.append(" - (request: ");
|
||||||
|
switch (getState()) {
|
||||||
|
case OPEN:
|
||||||
|
if (Boolean.TRUE.equals(getValue())) {
|
||||||
|
buf.append("OPEN");
|
||||||
|
} else {
|
||||||
|
buf.append("CLOSE");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BOUND:
|
||||||
|
if (getValue() != null) {
|
||||||
|
buf.append("BIND");
|
||||||
|
} else {
|
||||||
|
buf.append("UNBIND");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CONNECTED:
|
||||||
|
if (getValue() != null) {
|
||||||
|
buf.append("CONNECT");
|
||||||
|
} else {
|
||||||
|
buf.append("DISCONNECT");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case INTEREST_OPS:
|
||||||
|
buf.append("CHANGE_INTEREST");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buf.append(getState().name());
|
||||||
|
buf.append(": ");
|
||||||
|
buf.append(getValue());
|
||||||
|
}
|
||||||
|
buf.append(')');
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -37,27 +37,43 @@ import java.net.SocketAddress;
|
|||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultMessageEvent extends DefaultChannelEvent implements
|
public final class DownstreamMessageEvent implements MessageEvent {
|
||||||
MessageEvent {
|
|
||||||
|
|
||||||
|
private final Channel channel;
|
||||||
|
private final ChannelFuture future;
|
||||||
private final Object message;
|
private final Object message;
|
||||||
private final SocketAddress remoteAddress;
|
private final SocketAddress remoteAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultMessageEvent(
|
public DownstreamMessageEvent(
|
||||||
Channel channel, ChannelFuture future,
|
Channel channel, ChannelFuture future,
|
||||||
Object message, SocketAddress remoteAddress) {
|
Object message, SocketAddress remoteAddress) {
|
||||||
|
|
||||||
super(channel, future);
|
if (channel == null) {
|
||||||
|
throw new NullPointerException("channel");
|
||||||
|
}
|
||||||
|
if (future == null) {
|
||||||
|
throw new NullPointerException("future");
|
||||||
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
throw new NullPointerException("message");
|
throw new NullPointerException("message");
|
||||||
}
|
}
|
||||||
|
this.channel = channel;
|
||||||
|
this.future = future;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.remoteAddress = remoteAddress;
|
this.remoteAddress = remoteAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getMessage() {
|
public Object getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -69,9 +85,9 @@ public class DefaultMessageEvent extends DefaultChannelEvent implements
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (remoteAddress == null) {
|
if (remoteAddress == null) {
|
||||||
return super.toString() + " - (message: " + message + ')';
|
return super.toString() + " - (write: " + message + ')';
|
||||||
} else {
|
} else {
|
||||||
return super.toString() + " - (message: " + message + ", " + remoteAddress + ')';
|
return super.toString() + " - (write: " + message + ", " + remoteAddress + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.channel;
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
import static org.jboss.netty.channel.Channels.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link ChannelStateEvent} implementation.
|
* The default {@link ChannelStateEvent} implementation.
|
||||||
*
|
*
|
||||||
@ -31,27 +33,38 @@ package org.jboss.netty.channel;
|
|||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultChannelStateEvent extends DefaultChannelEvent implements
|
public final class UpstreamChannelStateEvent implements ChannelStateEvent {
|
||||||
ChannelStateEvent {
|
|
||||||
|
|
||||||
|
private final Channel channel;
|
||||||
private final ChannelState state;
|
private final ChannelState state;
|
||||||
private final Object value;
|
private final Object value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultChannelStateEvent(
|
public UpstreamChannelStateEvent(
|
||||||
Channel channel, ChannelFuture future,
|
Channel channel, ChannelState state, Object value) {
|
||||||
ChannelState state, Object value) {
|
|
||||||
|
|
||||||
super(channel, future);
|
if (channel == null) {
|
||||||
|
throw new NullPointerException("channel");
|
||||||
|
}
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
throw new NullPointerException("state");
|
throw new NullPointerException("state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.channel = channel;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelFuture getFuture() {
|
||||||
|
return succeededFuture(getChannel());
|
||||||
|
}
|
||||||
|
|
||||||
public ChannelState getState() {
|
public ChannelState getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -62,9 +75,9 @@ public class DefaultChannelStateEvent extends DefaultChannelEvent implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String parentString = super.toString();
|
String channelString = getChannel().toString();
|
||||||
StringBuilder buf = new StringBuilder(parentString.length() + 64);
|
StringBuilder buf = new StringBuilder(channelString.length() + 64);
|
||||||
buf.append(parentString);
|
buf.append(channelString);
|
||||||
buf.append(" - (state: ");
|
buf.append(" - (state: ");
|
||||||
switch (getState()) {
|
switch (getState()) {
|
||||||
case OPEN:
|
case OPEN:
|
@ -22,8 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.netty.channel;
|
package org.jboss.netty.channel;
|
||||||
|
|
||||||
|
import static org.jboss.netty.channel.Channels.*;
|
||||||
|
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link ChannelEvent} implementation.
|
* The default {@link MessageEvent} implementation. It is recommended to
|
||||||
|
* use {@link Channels#messageEvent(Channel, ChannelFuture, Object)} and
|
||||||
|
* {@link Channels#messageEvent(Channel, ChannelFuture, Object, SocketAddress)}
|
||||||
|
* to create a new {@link MessageEvent} instance rather than calling the
|
||||||
|
* constructor explicitly.
|
||||||
*
|
*
|
||||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||||
* @author Trustin Lee (tlee@redhat.com)
|
* @author Trustin Lee (tlee@redhat.com)
|
||||||
@ -31,38 +39,51 @@ package org.jboss.netty.channel;
|
|||||||
* @version $Rev$, $Date$
|
* @version $Rev$, $Date$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultChannelEvent implements ChannelEvent {
|
public final class UpstreamMessageEvent implements MessageEvent {
|
||||||
|
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
private final ChannelFuture future;
|
private final Object message;
|
||||||
|
private final SocketAddress remoteAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*/
|
*/
|
||||||
public DefaultChannelEvent(Channel channel, ChannelFuture future) {
|
public UpstreamMessageEvent(
|
||||||
|
Channel channel, Object message, SocketAddress remoteAddress) {
|
||||||
|
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
throw new NullPointerException("channel");
|
throw new NullPointerException("channel");
|
||||||
}
|
}
|
||||||
if (future == null) {
|
if (message == null) {
|
||||||
throw new NullPointerException("future");
|
throw new NullPointerException("message");
|
||||||
}
|
}
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.future = future;
|
this.message = message;
|
||||||
|
this.remoteAddress = remoteAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Channel getChannel() {
|
public Channel getChannel() {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ChannelFuture getFuture() {
|
public ChannelFuture getFuture() {
|
||||||
return future;
|
return succeededFuture(getChannel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SocketAddress getRemoteAddress() {
|
||||||
|
return remoteAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link String} representation of this event.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return channel.toString();
|
if (remoteAddress == null) {
|
||||||
|
return super.toString() + " - (received: " + message + ')';
|
||||||
|
} else {
|
||||||
|
return super.toString() + " - (received: " + message + ", " + remoteAddress + ')';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user