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


Java Channels.write方法代码示例

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


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

示例1: writeRequested

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
		throws Exception {
	RpcRequest request = (RpcRequest) e.getMessage();
	ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
	//先写入标示的魔数
	baos.write(Constants.MAGIC_BYTES);
	MySerializerFactory.getInstance(Constants.DEFAULT_RPC_CODE_MODE).encodeRequest(baos, request);
	ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(baos.toByteArray());
	Channels.write(ctx, e.getFuture(), buffer);
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:12,代码来源:RpcRequestEncode.java

示例2: writeRequested

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
		throws Exception {
	RpcResponse response = (RpcResponse) e.getMessage();
	ByteArrayOutputStream baos = new ByteArrayOutputStream(16384);
	//先写入标示的魔数
	baos.write(Constants.MAGIC_BYTES);
	MySerializerFactory.getInstance(Constants.DEFAULT_RPC_CODE_MODE).encodeResponse(baos, response);
	ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(baos.toByteArray());
	Channels.write(ctx, e.getFuture(), buffer);
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:12,代码来源:RpcResponseEncode.java

示例3: writeRequested

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
		throws Exception {
	/* Create a newly ChannelBuffer */
	ChannelBuffer frmBuf = ChannelBuffers.dynamicBuffer();		
	/* Get a IMessage Object */
	IMessage sMsg = (IMessage) e.getMessage();
	/* Transfer the object to a byte array */
	byte[] frameContent = null;
			
	if((sMsg instanceof CPhotoUpdateMsg))
	{
		frmBuf.writeInt(1);
		frmBuf.writeInt(((CPhotoUpdateMsg)sMsg).getPhoto().length);
		frmBuf.writeInt(((CPhotoUpdateMsg)sMsg).getUserId());
		frmBuf.writeBytes(((CPhotoUpdateMsg)sMsg).getPhoto(), 0, ((CPhotoUpdateMsg)sMsg).getPhoto().length);
	}
	else
	{
		frameContent = sMsg.toString().getBytes(Config.PACKAGE_ENCODE);
		frmBuf.writeInt(0);
		/* Write the content length to the buffer */
		frmBuf.writeInt(frameContent.length);
		/* Write the content to the buffer */
		frmBuf.writeBytes(frameContent, 0, frameContent.length);
	}
			
	
	Channels.write(ctx, e.getFuture(), frmBuf);
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:31,代码来源:PackageEncoder.java

示例4: handleDownstream

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
public void handleDownstream(
          final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
      if (!(evt instanceof MessageEvent)) {
          ctx.sendDownstream(evt);
          return;
      }

      MessageEvent e = (MessageEvent) evt;
      
      if (e.getMessage() instanceof ChunkedInput) {
          ctx.sendDownstream(evt);
          return;
      }
      
      ChannelBufferOutputStream bout =
          new ChannelBufferOutputStream(dynamicBuffer(
                  estimatedLength, ctx.getChannel().getConfig().getBufferFactory()));
      bout.write(LENGTH_PLACEHOLDER);
      final CompactObjectOutputStream oout = new CompactObjectOutputStream(bout);
      try {
       oout.writeObject(e.getMessage());
       ExternalizeUtil.writeCollection(oout, oout.getReferences());
       oout.flush();
       oout.close();
      } catch (Throwable t) {
      	throw new FailedWriteException(e.getMessage(), t);
      }
      ChannelBuffer encoded = bout.buffer();
      encoded.setInt(0, encoded.writerIndex() - 4);
      write(ctx, e.getFuture(), encoded, e.getRemoteAddress());
for (InputStream is : oout.getStreams()) {
	Channels.write(ctx.getChannel(), new AnonymousChunkedStream(new BufferedInputStream(is, CHUNK_SIZE)));
}
  }
 
开发者ID:kenweezy,项目名称:teiid,代码行数:35,代码来源:ObjectEncoder.java

示例5: flush

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void flush() {
	this.dataOut = null;
	this.writer = null;
	Channels.write(this.ctx.getChannel(), null);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:7,代码来源:PgBackendProtocol.java

示例6: sendContents

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
private void sendContents() {
	ChannelBuffer cb = this.dataOut;
	this.dataOut = null;
	this.writer = null;
	Channels.write(this.ctx, this.message.getFuture(), cb, this.message.getRemoteAddress());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:7,代码来源:PgBackendProtocol.java


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