当前位置: 首页>>代码示例>>Java>>正文


Java MessageEvent.getRemoteAddress方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:RpcUtil.java

示例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());
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:30,代码来源:BasePipelineFactory.java


注:本文中的org.jboss.netty.channel.MessageEvent.getRemoteAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。