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


Java ChannelHandlerContext.write方法代码示例

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


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

示例1: processMessageReceived

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void processMessageReceived(ChannelHandlerContext ctx, RemotingCommand msg) {
    HashMap<String, String> map = msg.getExtFields();
    String key = map.get("action");
    switch (key) {
        case "authorize":
            auth(ctx, msg);
            break;

        case "token":
            token(ctx, msg);
            break;

        case "access":
            access(ctx, msg);
            break;

        default:
            break;
    }
    ctx.write(msg);
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:23,代码来源:OAuth2ServerHandler.java

示例2: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
    if (msg instanceof FMLProxyPacket)
    {
        if (side == Side.CLIENT)
        {
            //Client to server large packets are not supported to prevent client being bad.
            ctx.write(((FMLProxyPacket) msg).toC17Packet(), promise);
        }
        else
        {
            List<Packet<INetHandlerPlayClient>> parts = ((FMLProxyPacket)msg).toS3FPackets();
            for (Packet<INetHandlerPlayClient> pkt : parts)
            {
                ctx.write(pkt, promise);
            }
        }
    }
    else
    {
        ctx.write(msg, promise);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:NetworkDispatcher.java

示例3: writeMessageToChannel

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void writeMessageToChannel ( final ChannelHandlerContext ctx, final ByteBuf data, final ChannelPromise promise )
{
    final int seq = this.ackBuffer.addMessage ( data );

    if ( promise == null )
    {
        ctx.write ( new InformationTransfer ( seq, this.receiveCounter, data ) );
    }
    else
    {
        ctx.write ( new InformationTransfer ( seq, this.receiveCounter, data ), promise );
    }

    logger.trace ( "Enqueued message as {} : {}", seq, data );

    // we can stop timer #2 here ... will be restarted by receive
    this.timer2.stop ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:MessageChannel.java

示例4: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write ( final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise ) throws Exception
{
    if ( msg instanceof OpenResponse )
    {
        writeOpenResponse ( ctx, (OpenResponse)msg, promise );
    }
    else if ( msg instanceof SyslogResponse )
    {
        writeGenericResponse ( ctx, (AbstractGenericResponse)msg, promise );
    }
    else if ( msg instanceof ServerCloseMessage )
    {
        ctx.write ( new Frame ( 0, "serverclose", (ByteBuf)null ) );
    }
    else
    {
        super.write ( ctx, msg, promise );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:FrameProcessor.java

示例5: sendHandshakeOptionHagglingReply

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void sendHandshakeOptionHagglingReply(ChannelHandlerContext ctx, int option, int error, ByteBuf data) throws IOException {
    ByteBuf optionReply = ctx.alloc().buffer(18);
    optionReply.writeLong(Protocol.HANDSHAKE_REPLY_MAGIC);
    optionReply.writeInt(option);
    optionReply.writeInt(error); // aka. reply type
    int len = 0;
    if (data != null)
        len = data.readableBytes();
    optionReply.writeInt(len);
    ctx.write(optionReply);
    if (data != null)
        ctx.write(data);
}
 
开发者ID:MineboxOS,项目名称:tools,代码行数:14,代码来源:HandshakePhase.java

示例6: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write ( final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise ) throws Exception
{
    logger.trace ( "Write {}", msg );
    synchronized ( this )
    {
        if ( msg instanceof DataTransmissionMessage )
        {
            switch ( (DataTransmissionMessage)msg )
            {
                case REQUEST_START:
                    ctx.write ( new UnnumberedControl ( Function.STARTDT_ACT ), promise );
                    break;
                case CONFIRM_START:
                    ctx.write ( new UnnumberedControl ( Function.STARTDT_CONFIRM ), promise );
                    break;
                case REQUEST_STOP:
                    ctx.write ( new UnnumberedControl ( Function.STOPDT_ACT ), promise );
                    break;
                case CONFIRM_STOP:
                    ctx.write ( new UnnumberedControl ( Function.STOPDT_CONFIRM ), promise );
                    break;
                default:
                    throw new EncoderException ( String.format ( "Unknown data transmission message: %s", msg ) );
            }
        }
        else if ( msg == MessageSource.NOTIFY_TOKEN )
        {
            handleMessageSourceUpdates ( ctx );
        }
        else
        {
            handleMessageWrite ( ctx, msg, promise );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:37,代码来源:MessageChannel.java

示例7: channelRead0

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx,
		SocksRequest socksRequest) throws Exception {
	switch (socksRequest.requestType()) {
	case INIT: {
		logger.info("localserver init");
		ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
		ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
		break;
	}
	case AUTH:
		ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
		ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
		break;
	case CMD:
		SocksCmdRequest req = (SocksCmdRequest) socksRequest;
		if (req.cmdType() == SocksCmdType.CONNECT) {
			logger.info("localserver connect");
			ctx.pipeline().addLast(new SocksServerConnectHandler(config));
			ctx.pipeline().remove(this);
			ctx.fireChannelRead(socksRequest);
		} else {
			ctx.close();
		}
		break;
	case UNKNOWN:
		ctx.close();
		break;
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:31,代码来源:SocksServerHandler.java

示例8: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
    if (msg instanceof AmqpDeliverMessage) {
        ((AmqpDeliverMessage) msg).write(ctx);
    } else  {
        ctx.write(msg, promise);
    }
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:9,代码来源:AmqpMessageWriter.java

示例9: channelRead

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx,
    Object msg) {
    ByteBuf in = (ByteBuf) msg;
    System.out.println("Server received: " + in.toString(CharsetUtil.UTF_8));
    ctx.write(in);
}
 
开发者ID:zy416548283,项目名称:NettyStudy,代码行数:8,代码来源:EchoServerHandler.java

示例10: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object message, ChannelPromise promise)
        throws Exception
{
    if (message instanceof ThriftRequest) {
        ThriftRequest thriftRequest = (ThriftRequest) message;
        sendMessage(ctx, thriftRequest, promise);
    }
    else {
        ctx.write(message, promise);
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:13,代码来源:ThriftClientHandler.java

示例11: handleMessage

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(ChannelHandlerContext ctx, HandshakeRequest msg) {
	ClientMessage message = ClientMessage.SUCCESSFUL_CONNECTION;
	if (msg.getVersion() != Quavo.VERSION) {
		message = ClientMessage.OUT_OF_DATE;
	}

	ctx.write(new HandshakeResponse(message));
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:10,代码来源:HandshakeListener.java

示例12: handleException

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void handleException(ChannelHandlerContext ctx, Exception e) {
    if (e instanceof UnauthorizedException) {
        ctx.write(Response.buildDefaultFullHttpResponse(HttpResponseStatus.UNAUTHORIZED));
    }
    else if (e instanceof ForbiddenException) {
        ctx.write(Response.buildDefaultFullHttpResponse(HttpResponseStatus.FORBIDDEN));
    }
    else {
        ctx.write(Response.buildDefaultFullHttpResponse(HttpResponseStatus.INTERNAL_SERVER_ERROR));
    }
}
 
开发者ID:zhyzhyzhy,项目名称:Ink,代码行数:12,代码来源:HttpRequestHandler.java

示例13: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    if (msg instanceof Heartbeat) {
        ctx.write(msg, promise);
    } else {
        super.write(ctx, msg, promise);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:9,代码来源:NettyClientIdleStateHandler.java

示例14: write

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
    if (!(msg instanceof FMLProxyPacket))
    {
        return;
    }
    FMLProxyPacket pkt = (FMLProxyPacket) msg;
    OutboundTarget outboundTarget;
    Object args = null;
    NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
    // INTERNAL message callback - let it pass out
    if (dispatcher != null)
    {
        ctx.write(msg, promise);
        return;
    }

    outboundTarget = ctx.channel().attr(FML_MESSAGETARGET).get();
    Side channelSide = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();
    if (outboundTarget != null && outboundTarget.allowed.contains(channelSide))
    {
        args = ctx.channel().attr(FML_MESSAGETARGETARGS).get();
        outboundTarget.validateArgs(args);
    }
    else if (channelSide == Side.CLIENT)
    {
        outboundTarget = OutboundTarget.TOSERVER;
    }
    else
    {
        throw new FMLNetworkException("Packet arrived at the outbound handler without a valid target!");
    }

    List<NetworkDispatcher> dispatchers = outboundTarget.selectNetworks(args, ctx, pkt);

    // This will drop the messages into the output queue at the embedded channel
    if (dispatchers == null)
    {
        ctx.write(msg, promise);
        return;
    }
    for (NetworkDispatcher targetDispatcher : dispatchers)
    {
        targetDispatcher.sendProxy((FMLProxyPacket) msg);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:48,代码来源:FMLOutboundHandler.java

示例15: handleMessage

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(ChannelHandlerContext ctx, XOREncryptionRequest msg) {
	ctx.write(new XOREncryptionResponse(msg.getKey()));
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:5,代码来源:XOREncryptionListener.java


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