本文整理汇总了Java中org.jboss.netty.channel.MessageEvent.getRemoteAddress方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getRemoteAddress方法的具体用法?Java MessageEvent.getRemoteAddress怎么用?Java MessageEvent.getRemoteAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.channel.MessageEvent
的用法示例。
在下文中一共展示了MessageEvent.getRemoteAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageReceived
import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {
ChannelBuffer buf = (ChannelBuffer) e.getMessage();
ByteBuffer b = buf.toByteBuffer().asReadOnlyBuffer();
XDR in = new XDR(b, XDR.State.READING);
RpcInfo info = null;
try {
RpcCall callHeader = RpcCall.read(in);
ChannelBuffer dataBuffer = ChannelBuffers.wrappedBuffer(in.buffer()
.slice());
info = new RpcInfo(callHeader, dataBuffer, ctx, e.getChannel(),
e.getRemoteAddress());
} catch (Exception exc) {
LOG.info("Malformed RPC request from " + e.getRemoteAddress());
}
if (info != null) {
Channels.fireMessageReceived(ctx, info);
}
}
示例2: log
import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void log(ChannelEvent e) {
if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
StringBuilder msg = new StringBuilder();
msg.append("[").append(String.format("%08X", e.getChannel().getId())).append(": ");
msg.append(((InetSocketAddress) e.getChannel().getLocalAddress()).getPort());
if (e instanceof DownstreamMessageEvent) {
msg.append(" > ");
} else {
msg.append(" < ");
}
if (event.getRemoteAddress() != null) {
msg.append(((InetSocketAddress) event.getRemoteAddress()).getHostString());
} else {
msg.append("null");
}
msg.append("]");
if (event.getMessage() instanceof ChannelBuffer) {
msg.append(" HEX: ");
msg.append(ChannelBuffers.hexDump((ChannelBuffer) event.getMessage()));
}
Log.debug(msg.toString());
}
}