當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。