本文整理匯總了Java中org.jboss.netty.channel.Channels.future方法的典型用法代碼示例。如果您正苦於以下問題:Java Channels.future方法的具體用法?Java Channels.future怎麽用?Java Channels.future使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.netty.channel.Channels
的用法示例。
在下文中一共展示了Channels.future方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: send
import org.jboss.netty.channel.Channels; //導入方法依賴的package包/類
/**
* Sends this response to all the passed channels as a {@link TextWebSocketFrame}
* @param listener A channel future listener to attach to each channel future. Ignored if null.
* @param channels The channels to send this response to
* @return An array of the futures for the write of this response to each channel written to
*/
public ChannelFuture[] send(ChannelFutureListener listener, Channel...channels) {
if(channels!=null && channels.length>0) {
Set<ChannelFuture> futures = new HashSet<ChannelFuture>(channels.length);
if(opCode==null) {
opCode = "ok";
}
TextWebSocketFrame frame = new TextWebSocketFrame(this.toChannelBuffer());
for(Channel channel: channels) {
if(channel!=null && channel.isWritable()) {
ChannelFuture cf = Channels.future(channel);
if(listener!=null) cf.addListener(listener);
channel.getPipeline().sendDownstream(new DownstreamMessageEvent(channel, cf, frame, channel.getRemoteAddress()));
futures.add(cf);
}
}
return futures.toArray(new ChannelFuture[futures.size()]);
}
return EMPTY_CHANNEL_FUTURE_ARR;
}