List of usage examples for io.netty.channel ChannelHandlerContext fireChannelActive
@Override ChannelHandlerContext fireChannelActive();
From source file:com.supermy.im.netty.handler.ImServerHandler.java
License:Apache License
/** * //from w w w . jav a 2 s. c om * * @param ctx * @throws Exception */ @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { Assert.notNull(this.channelRepository, "[Assertion failed] - ChannelRepository is required; it must not be null"); ctx.fireChannelActive(); logger.debug(ctx.channel().remoteAddress()); String channelKey = ctx.channel().remoteAddress().toString(); channelRepository.put(channelKey, ctx.channel()); ctx.writeAndFlush("Your channel key is " + channelKey + "\n\r"); logger.debug("Binded Channel Count is " + this.channelRepository.size()); }
From source file:com.zaradai.distributor.messaging.netty.handler.AbstractHandshakeHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext handlerContext) throws Exception { handshake(handlerContext);//from w w w . j a va2 s. c o m handlerContext.fireChannelActive(); }
From source file:de.saxsys.synchronizefx.netty.base.client.NetworkEventHandlerClient.java
License:Open Source License
@Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { LOG.info("Connected to the server."); ctx.fireChannelActive(); }
From source file:de.saxsys.synchronizefx.netty.base.server.NetworkEventHandlerServer.java
License:Open Source License
@Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { LOG.info("A client connected from the address " + ctx.channel().remoteAddress()); userCallback.onConnect(ctx.channel()); ctx.fireChannelActive(); }
From source file:divconq.net.ssl.SslHandler.java
License:Apache License
@Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { if (!startTls && engine.getUseClientMode()) { // issue and handshake and add a listener to it which will fire an exception event if // an exception was thrown while doing the handshake handshake().addListener(new GenericFutureListener<Future<Channel>>() { @Override/*w ww .j ava 2 s .com*/ public void operationComplete(Future<Channel> future) throws Exception { if (!future.isSuccess()) { logger.debug("Failed to complete handshake", future.cause()); ctx.close(); } } }); } ctx.fireChannelActive(); }
From source file:io.lettuce.core.PlainChannelInitializer.java
License:Apache License
static void pingBeforeActivate(AsyncCommand<?, ?, ?> cmd, CompletableFuture<Boolean> initializedFuture, ChannelHandlerContext ctx, ClientResources clientResources, Duration timeout) throws Exception { ctx.fireUserEventTriggered(new PingBeforeActivate(cmd)); Runnable timeoutGuard = () -> { if (cmd.isDone() || initializedFuture.isDone()) { return; }//from w ww. j a v a 2s . co m initializedFuture.completeExceptionally(ExceptionFactory .createTimeoutException("Cannot initialize channel (PING before activate)", timeout)); }; Timeout timeoutHandle = clientResources.timer().newTimeout(t -> { if (clientResources.eventExecutorGroup().isShuttingDown()) { timeoutGuard.run(); return; } clientResources.eventExecutorGroup().submit(timeoutGuard); }, timeout.toNanos(), TimeUnit.NANOSECONDS); cmd.whenComplete((o, throwable) -> { timeoutHandle.cancel(); if (throwable == null) { ctx.fireChannelActive(); initializedFuture.complete(true); } else { initializedFuture.completeExceptionally(throwable); } }); }
From source file:io.netlibs.bgp.netty.handlers.BGPv4ClientEndpoint.java
License:Apache License
@Override // public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception public void channelActive(final ChannelHandlerContext ctx) throws Exception { log.info("connected to client " + ctx.channel().remoteAddress()); final BGPv4FSM fsm = this.fsmRegistry.lookupFSM((InetSocketAddress) ctx.channel().remoteAddress()); if (fsm == null) { log.error("Internal Error: client for address " + ctx.channel().remoteAddress() + " is unknown"); ctx.channel().close();//from ww w .j a va2 s. c o m } else { final ChannelPipeline pipeline = ctx.pipeline(); final PeerConnectionInformation pci = fsm.getPeerConnectionInformation(); pipeline.forEach(e -> { ChannelHandler handler = e.getValue(); if (handler.getClass().isAnnotationPresent(PeerConnectionInformationAware.class)) { log.info("attaching peer connection information " + pci + " to handler " + e.getKey() + " for client " + ctx.channel().remoteAddress()); pipeline.context(e.getKey()).attr(PEER_CONNECTION_INFO).set(pci); } }); fsm.handleClientConnected(ctx.channel()); ctx.fireChannelActive(); } }
From source file:io.netlibs.bgp.netty.handlers.BGPv4ServerEndpoint.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { final Channel clientChannel = ctx.channel(); log.info("connected to client " + clientChannel.remoteAddress()); BGPv4FSM fsm = fsmRegistry.lookupFSM(((InetSocketAddress) clientChannel.remoteAddress()).getAddress()); if (fsm == null) { log.error("Internal Error: client for address " + clientChannel.remoteAddress() + " is unknown"); clientChannel.close();//from ww w . j a v a2 s . c o m } else if (fsm.isCanAcceptConnection()) { ChannelPipeline pipeline = ctx.pipeline(); PeerConnectionInformation pci = fsm.getPeerConnectionInformation(); pipeline.forEach(e -> { ChannelHandler handler = e.getValue(); if (handler.getClass().isAnnotationPresent(PeerConnectionInformationAware.class)) { log.info("attaching peer connection information {} to handler {} for client {}", pci, e.getKey(), clientChannel.remoteAddress()); pipeline.context(handler).attr(BGPv4ClientEndpoint.PEER_CONNECTION_INFO).set(pci); } }); fsm.handleServerOpened(clientChannel); trackedChannels.add(clientChannel); ctx.fireChannelActive(); } else { log.info("Connection from client {} cannot be accepted", clientChannel.remoteAddress()); clientChannel.close(); } }
From source file:nenea.client.operation.UptimeClientHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) { if (startTime < 0) { startTime = System.currentTimeMillis(); }/*from w w w . j av a 2 s.co m*/ println("Connected to: " + ctx.channel().remoteAddress()); ctx.fireChannelActive(); }
From source file:net.javaforge.netty.servlet.bridge.ServletBridgeHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { log.debug("Opening new channel: {}", ctx.channel().id()); ServletBridgeWebapp.get().getSharedChannelGroup().add(ctx.channel()); ctx.fireChannelActive(); }