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


Java MessageEvent.getMessage方法代码示例

本文整理汇总了Java中org.jboss.netty.channel.MessageEvent.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getMessage方法的具体用法?Java MessageEvent.getMessage怎么用?Java MessageEvent.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.channel.MessageEvent的用法示例。


在下文中一共展示了MessageEvent.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  if (e.getMessage() instanceof ChannelBuffer) {
    ChannelBuffer buffer = (ChannelBuffer) e.getMessage();

    int bytesToRead = Math.min(currentChunkSize - bytesRead, buffer.readableBytes());
    buffer.readBytes(getMailEnvelope().getMessageOutputStream(), bytesToRead);
    bytesRead += bytesToRead;

    if (bytesRead == currentChunkSize) {
      stopCapturingData();
    }

    return;
  }

  super.messageReceived(ctx, e);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:19,代码来源:ChunkingExtension.java

示例2: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
	Object msg = e.getMessage();
	if (!(msg instanceof RpcRequest)) {
		logger.error("not RpcRequest received!");
		return;
	}
	RpcRequest request = (RpcRequest) msg;
	ctx.setAttachment(request);

	RpcResponse response = new RpcResponse(request.getRequestID());
	try {
		Object result = handle(request);
		response.setResult(result);
	} catch (Throwable t) {
		logger.error("handle rpc request fail! request:"+request, t);
		response.setException(t);
	}
	e.getChannel().write(response);
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:21,代码来源:NettyRpcServerHandler.java

示例3: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
        throws Exception {
    if (e.getMessage() instanceof List) {
        @SuppressWarnings("unchecked")
        List<OFMessage> msglist = (List<OFMessage>) e.getMessage();


        for (OFMessage ofm : msglist) {
            // Do the actual packet processing
            state.processOFMessage(this, ofm);
        }
    } else {
        state.processOFMessage(this, (OFMessage) e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OFChannelHandler.java

示例4: 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

示例5: sendToHelpMeMsg

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
public static void sendToHelpMeMsg(MessageEvent e) {
		SHelpMeMsg msg = (SHelpMeMsg) e.getMessage();
		synchronized (String.class) {
		if(DataHiBang.sHelpMeMsgList.size()>=10) {
			DataHiBang.sHelpMeMsgList.remove(0);
		}
		DataHiBang.sHelpMeMsgList.add(msg);
		}
		if (isCurrUI(Config.TAG_MessageActivity)) {
			sHelpMeMsgListener.onHelpMeMsgReveived(msg);
		} else {
//			Intent intent = new Intent(currContext, MessageActivity.class);
			myMainTabListener.onMsgReveived(msg);
			Intent intent = new Intent(currContext, InformationActivity.class);
			Bundle bundle = new Bundle();
			bundle.putInt("TAG", Config.TAG_HelpMeMessage);
			MySHelpMeMsg helpMeMsg = new MySHelpMeMsg(msg);
			bundle.putSerializable("helpMeMessage", helpMeMsg);
			
			intent.putExtras(bundle);
			myNotifi(1002,intent, msg.getHelpName(), msg.getReqItem());
		}
	}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:24,代码来源:SMsgManage.java

示例6: sendToChat

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
public static void sendToChat(MessageEvent e) {
	SChatMessage msg = (SChatMessage) e.getMessage();
	if (msg.getSenderID() == chattingUserId) {
		DBManage.addSChatMsg(msg, false);
		myChattingListener.onMsgReceived(msg);
	} else {
		DBManage.addSChatMsg(msg, true);
		Intent intent = new Intent(currContext, ChatActivity.class);
		Bundle bundle = new Bundle();
		bundle.putInt("friendId", msg.getSenderID());
		bundle.putString("friendName", msg.getReceiverName());
		intent.putExtras(bundle);
		String title = "嗨帮-聊天消息 (共1条未读)";
		myNotifi(1003,intent,title,msg.getChatContent());
		
		// sChatMessageListener.onMsgReveived(msg);
	}
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:19,代码来源:SMsgManage.java

示例7: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx,
                            MessageEvent e) throws Exception {
    Object message = e.getMessage();
    if (message instanceof SyncMessage) {
        handleSyncMessage((SyncMessage)message, ctx.getChannel());
    } else if (message instanceof List) {
        for (Object i : (List<?>)message) {
            if (i instanceof SyncMessage) {
                try {
                    handleSyncMessage((SyncMessage)i,
                                         ctx.getChannel());
                } catch (Exception ex) {
                    Channels.fireExceptionCaught(ctx, ex);
                }
            }
        }
    } else {
        handleUnknownMessage(ctx, message);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:AbstractRPCChannelHandler.java

示例8: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
    throws Exception {
  RpcInfo info = (RpcInfo) e.getMessage();
  RpcCall call = (RpcCall) info.header();
  
  SocketAddress remoteAddress = info.remoteAddress();
  if (LOG.isTraceEnabled()) {
    LOG.trace(program + " procedure #" + call.getProcedure());
  }
  
  if (this.progNumber != call.getProgram()) {
    LOG.warn("Invalid RPC call program " + call.getProgram());
    sendAcceptedReply(call, remoteAddress, AcceptState.PROG_UNAVAIL, ctx);
    return;
  }

  int ver = call.getVersion();
  if (ver < lowProgVersion || ver > highProgVersion) {
    LOG.warn("Invalid RPC call version " + ver);
    sendAcceptedReply(call, remoteAddress, AcceptState.PROG_MISMATCH, ctx);
    return;
  }
  
  handleInternal(ctx, info);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:RpcProgram.java

示例9: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  if (e.getMessage() instanceof List) {
    @SuppressWarnings("unchecked")
    List<ResponseWrapper> responses = (List<ResponseWrapper>) e.getMessage();
    if (isDebugEnabled) {
      // for performance trace
      LOGGER.debug("receive response list from server: " + ctx.getChannel().getRemoteAddress() + ",list size is:" + responses.size());
    }
    client.putResponses(responses);
  } else if (e.getMessage() instanceof ResponseWrapper) {
    ResponseWrapper response = (ResponseWrapper) e.getMessage();
    if (isDebugEnabled) {
      // for performance trace
      LOGGER
          .debug("receive response list from server: " + ctx.getChannel().getRemoteAddress() + ",request is:" + response.getRequestId());
    }
    client.putResponse(response);
  } else {
    LOGGER.error("receive message error,only support List || ResponseWrapper");
    throw new Exception("receive message error,only support List || ResponseWrapper");
  }
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:23,代码来源:NettyClientHandler.java

示例10: createExchange

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public Exchange createExchange(ChannelHandlerContext ctx, MessageEvent messageEvent) throws Exception {
    Exchange exchange = createExchange();

    // use the http binding
    HttpRequest request = (HttpRequest) messageEvent.getMessage();
    Message in = getNettyHttpBinding().toCamelMessage(request, exchange, getConfiguration());
    exchange.setIn(in);
    
    // setup the common message headers 
    updateMessageHeader(in, ctx, messageEvent);

    // honor the character encoding
    String contentType = in.getHeader(Exchange.CONTENT_TYPE, String.class);
    String charset = NettyHttpHelper.getCharsetFromContentType(contentType);
    if (charset != null) {
        exchange.setProperty(Exchange.CHARSET_NAME, charset);
        in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, charset);
    }

    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:NettyHttpEndpoint.java

示例11: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
  // Get handle from create response
  ChannelBuffer buf = (ChannelBuffer) e.getMessage();
  XDR rsp = new XDR(buf.array());
  if (rsp.getBytes().length == 0) {
    LOG.info("rsp length is zero, why?");
    return;
  }
  LOG.info("rsp length=" + rsp.getBytes().length);

  RpcReply reply = RpcReply.read(rsp);
  int xid = reply.getXid();
  // Only process the create response
  if (xid != 0x8000004c) {
    return;
  }
  int status = rsp.readInt();
  if (status != Nfs3Status.NFS3_OK) {
    LOG.error("Create failed, status =" + status);
    return;
  }
  LOG.info("Create succeeded");
  rsp.readBoolean(); // value follow
  handle = new FileHandle();
  handle.deserialize(rsp);
  channel = e.getChannel();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestOutOfOrderWrite.java

示例12: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception {
    if (config.isCorsSupportEnabled() && e.getMessage() instanceof HttpRequest) {
        request = (HttpRequest) e.getMessage();
        if (isPreflightRequest(request)) {
            handlePreflight(ctx, request);
            return;
        }
        if (config.isShortCircuit() && !validateOrigin()) {
            forbidden(ctx, request);
            return;
        }
    }
    super.messageReceived(ctx, e);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:CorsHandler.java

示例13: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    if (e.getMessage() instanceof List) {
        @SuppressWarnings("Unchecked")
        List<BgpMessage> msglist = (List<BgpMessage>) e.getMessage();
        for (BgpMessage pm : msglist) {
            // Do the actual packet processing
            state.processBgpMessage(this, pm);
        }
    } else {
        state.processBgpMessage(this, (BgpMessage) e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:BgpChannelHandler.java

示例14: sendToMeHelpMsg

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
public static void sendToMeHelpMsg(MessageEvent e) {
		SMeHelpMsg msg = (SMeHelpMsg) e.getMessage();
		for(SMeHelpMsg m : DataHiBang.sMeHelpMsgList) {
			if(m.getHelpUserID() == msg.getHelpUserID()) {
				return;
			}
		}
		synchronized (String.class) {
			if(DataHiBang.sMeHelpMsgList.size()>=10) {
				DataHiBang.sMeHelpMsgList.remove(0);
			}
			
			DataHiBang.sMeHelpMsgList.add(msg);
		}
		
//		DBManage.addMeHelpMsg(msg, true);
		if (isCurrUI(Config.TAG_MessageActivity)) {
			sMeHelpMsgListener.onMeHelpMsgReveived(msg);
		} else {
			myMainTabListener.onMsgReveived(msg);
			Intent intent = new Intent(currContext, InformationActivity.class);
			Bundle bundle = new Bundle();
			bundle.putInt("TAG", Config.TAG_MeHelpMessage);
			MySMeHelpMsg meHelpMsg = new MySMeHelpMsg(msg);
			bundle.putSerializable("meHelpMessage", meHelpMsg);
			intent.putExtras(bundle);
			myNotifi(1001,intent, msg.getHelpName(), msg.getReqItem());
		}
	}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:30,代码来源:SMsgManage.java

示例15: messageReceived

import org.jboss.netty.channel.MessageEvent; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
  ChannelBuffer buf = (ChannelBuffer) e.getMessage(); // Read reply
  if (!validMessageLength(buf.readableBytes())) {
    e.getChannel().close();
    return;
  }

  // handling fragment header for TCP, 4 bytes.
  byte[] fragmentHeader = Arrays.copyOfRange(buf.array(), 0, 4);
  int fragmentSize = XDR.fragmentSize(fragmentHeader);
  boolean isLast = XDR.isLastFragment(fragmentHeader);
  assert (fragmentSize == 28 && isLast == true);

  XDR xdr = new XDR();
  xdr.writeFixedOpaque(Arrays.copyOfRange(buf.array(), 4,
      buf.readableBytes()));

  RpcReply reply = RpcReply.read(xdr);
  if (reply.getState() == RpcReply.ReplyState.MSG_ACCEPTED) {
    RpcAcceptedReply acceptedReply = (RpcAcceptedReply) reply;
    handle(acceptedReply, xdr);
  } else {
    RpcDeniedReply deniedReply = (RpcDeniedReply) reply;
    handle(deniedReply);
  }
  e.getChannel().close(); // shutdown now that request is complete
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:RegistrationClient.java


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