本文整理匯總了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());
}
}