Example usage for io.netty.channel ChannelHandlerContext fireChannelActive

List of usage examples for io.netty.channel ChannelHandlerContext fireChannelActive

Introduction

In this page you can find the example usage for io.netty.channel ChannelHandlerContext fireChannelActive.

Prototype

@Override
    ChannelHandlerContext fireChannelActive();

Source Link

Usage

From source file:com.alibaba.dubbo.remoting.transport.netty.NettyClientHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();
}

From source file:com.alibaba.dubbo.remoting.transport.netty.NettyServerHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();

    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler);
    try {/*from   www. j  a  va 2  s. c  o  m*/
        if (channel != null) {
            channels.put(NetUtils.toAddressString((InetSocketAddress) ctx.channel().remoteAddress()), channel);
        }
        handler.connected(channel);
    } finally {
        NettyChannel.removeChannelIfDisconnected(ctx.channel());
    }
}

From source file:com.barchart.netty.client.pipeline.CapabilitiesRequest.java

License:BSD License

@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {

    ctx.writeAndFlush(new Capabilities() {

        @Override/*w  w  w .  ja  va2s  . co  m*/
        public Set<String> capabilities() {
            return Collections.emptySet();
        }

        @Override
        public Version version() {
            return null;
        }

        @Override
        public Version minVersion() {
            return null;
        }

    });

    ctx.fireChannelActive();

    ctx.pipeline().remove(this);

}

From source file:com.barchart.netty.common.pipeline.PingHandler.java

License:BSD License

@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {

    startPing(ctx);//  w w w. j  av  a  2s .c  o m

    ctx.fireChannelActive();

}

From source file:com.barchart.netty.common.pipeline.WebSocketConnectedNotifier.java

License:BSD License

@Override
public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt) throws Exception {

    if (evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE
            || evt == WebSocketServerProtocolHandler.ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) {

        ctx.fireChannelActive();
        ctx.fireUserEventTriggered(evt);

        for (final Object msg : messages)
            ctx.fireChannelRead(msg);//from w ww.j  ava 2  s . co  m

        messages.clear();

        ctx.pipeline().remove(this);

    } else {

        ctx.fireUserEventTriggered(evt);

    }

}

From source file:com.couchbase.client.core.endpoint.AbstractGenericHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    LOGGER.debug(logIdent(ctx, endpoint) + "Channel Active.");

    SocketAddress addr = ctx.channel().remoteAddress();
    if (addr instanceof InetSocketAddress) {
        // Avoid lookup, so just use the address
        remoteHostname = ((InetSocketAddress) addr).getAddress().getHostAddress();
    } else {/*from w  w w  .j a  va  2  s  . c  o  m*/
        // Should not happen in production, but in testing it might be different
        remoteHostname = addr.toString();
    }
    ctx.fireChannelActive();
}

From source file:com.couchbase.client.core.endpoint.dcp.DCPConnectionHandler.java

License:Apache License

/**
 * Dispatches incoming OPEN_CONNECTION responses and also initialize flow control.
 *
 * @param ctx the handler context.//from w  ww .jav a 2  s .  c  o  m
 * @param msg the incoming message to investigate.
 * @throws Exception if something goes wrong during negotiation.
 */
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
    if (msg.getOpcode() == DCPHandler.OP_OPEN_CONNECTION) {
        if (msg.getStatus() == KeyValueStatus.SUCCESS.code()) {
            if (env.dcpConnectionBufferSize() > 0) {
                FullBinaryMemcacheRequest request = controlRequest(ctx, ControlParameter.CONNECTION_BUFFER_SIZE,
                        env.dcpConnectionBufferSize());
                ChannelFuture future = ctx.writeAndFlush(request);
                future.addListener(new GenericFutureListener<Future<Void>>() {
                    @Override
                    public void operationComplete(Future<Void> future) throws Exception {
                        if (!future.isSuccess()) {
                            LOGGER.warn("Error during setting CONNECTION_BUFFER_SIZE for DCP connection: {}.",
                                    future);
                        }
                    }
                });
            } else {
                originalPromise.setSuccess();
                ctx.pipeline().remove(this);
                ctx.fireChannelActive();
            }
        } else {
            originalPromise.setFailure(
                    new IllegalStateException("Bad status for DCP Open Connection: " + msg.getStatus()));
        }
    } else if (msg.getOpcode() == DCPHandler.OP_CONTROL) {
        if (msg.getStatus() == KeyValueStatus.SUCCESS.code()) {
            originalPromise.setSuccess();
            ctx.pipeline().remove(this);
            ctx.fireChannelActive();
        } else {
            originalPromise.setFailure(new IllegalStateException(
                    "Bad status for setting CONNECTION_BUFFER_SIZE DCP Open Connection: " + msg.getStatus()));
        }
    }
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueFeatureHandler.java

License:Apache License

@Override
protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
    List<ServerFeatures> supported = new ArrayList<ServerFeatures>();

    ResponseStatus responseStatus = ResponseStatusConverter.fromBinary(msg.getStatus());
    if (responseStatus.isSuccess()) {
        while (msg.content().isReadable()) {
            supported.add(ServerFeatures.fromValue(msg.content().readShort()));
        }// w w  w .j  ava  2 s.co m
    } else {
        LOGGER.debug("HELLO Negotiation did not succeed ({}).", responseStatus);
    }

    LOGGER.debug("Negotiated supported features: {}", supported);
    ctx.fireUserEventTriggered(new ServerFeaturesEvent(supported));
    originalPromise.setSuccess();
    ctx.pipeline().remove(this);
    ctx.fireChannelActive();
}

From source file:com.crystal.chat.SecureChatServerHandler.java

License:Apache License

@Override
public void channelActive(final ChannelHandlerContext ctx) {
    // Once session is secured, send a greeting and register the channel to the global channel
    // list so the channel received the messages from others.

    /*ctx.pipeline().get(SslHandler.class).handshakeFuture().addListener(
        new GenericFutureListener<Future<Channel>>() {
            @Override/*www.j  a  v  a2 s .c  o m*/
            public void operationComplete(Future<Channel> future) throws Exception {
                ctx.writeAndFlush(
                        "Welcome to " + InetAddress.getLocalHost().getHostName() + " secure chat service!\n");
                ctx.writeAndFlush(
                        "Your session is protected by " +
                                ctx.pipeline().get(SslHandler.class).engine().getSession().getCipherSuite() +
                                " cipher suite.\n");
                        
                String rtmpurls = getUserlist();
                System.out.println("Servier active rtmpurls="+rtmpurls);
                ctx.writeAndFlush(rtmpurls+"\n");
                channels.add(ctx.channel());
            }
    });
    */
    ctx.fireChannelActive();
    /*String rtmpurls = getUserlist();
    System.out.println("Servier active rtmpurls="+rtmpurls);
    ctx.writeAndFlush(rtmpurls+"\n");
    channels.add(ctx.channel());*/
}

From source file:com.farsunset.cim.sdk.android.filter.CIMLoggingHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    if (debug) {/*from w w  w  . j  a va2s . co m*/
        Log.i(TAG, "OPENED" + getSessionInfo(ctx.channel()));
    }
    ctx.fireChannelActive();
}