* Updated the Javadoc of MessageEvent

* Improved how getRemoteAddress() works in DownstreamMessageEvent and UpstreamMessageEvent
This commit is contained in:
Trustin Lee 2009-07-18 07:43:13 +00:00
parent 7be842be05
commit 3610fa9608
3 changed files with 13 additions and 14 deletions

View File

@ -77,7 +77,11 @@ public class DownstreamMessageEvent implements MessageEvent {
}
public SocketAddress getRemoteAddress() {
if (remoteAddress != null) {
return remoteAddress;
} else {
return getChannel().getRemoteAddress();
}
}
@Override

View File

@ -45,10 +45,7 @@ public interface MessageEvent extends ChannelEvent {
Object getMessage();
/**
* Returns the remote address.
*
* @return the remote address. {@code null} if the remote address is
* same with the default remote address returned by {@link Channel#getRemoteAddress()}.
* Returns the remote address of the message.
*/
SocketAddress getRemoteAddress();
}

View File

@ -57,12 +57,7 @@ public class UpstreamMessageEvent implements MessageEvent {
}
this.channel = channel;
this.message = message;
if (remoteAddress != null) {
this.remoteAddress = remoteAddress;
} else {
this.remoteAddress = channel.getRemoteAddress();
}
}
public Channel getChannel() {
@ -78,13 +73,16 @@ public class UpstreamMessageEvent implements MessageEvent {
}
public SocketAddress getRemoteAddress() {
if (remoteAddress != null) {
return remoteAddress;
} else {
return getChannel().getRemoteAddress();
}
}
@Override
public String toString() {
// It's safe to use identity comparison in this case.
if (getRemoteAddress() == getChannel().getRemoteAddress()) {
if (getRemoteAddress() == null) {
return getChannel().toString() + " RECEIVED: " +
StringUtil.stripControlCharacters(getMessage());
} else {