/** * Start WebImageViewer. * @param fsimage the fsimage to load. * @throws IOException if fail to load the fsimage. */ @VisibleForTesting public void initServer(String fsimage) throws IOException { FSImageLoader loader = FSImageLoader.load(fsimage); ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("channelTracker", new SimpleChannelUpstreamHandler() { @Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { allChannels.add(e.getChannel()); } }); pipeline.addLast("httpDecoder", new HttpRequestDecoder()); pipeline.addLast("requestHandler", new FSImageHandler(loader)); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("httpEncoder", new HttpResponseEncoder()); bootstrap.setPipeline(pipeline); channel = bootstrap.bind(address); allChannels.add(channel); address = (InetSocketAddress) channel.getLocalAddress(); LOG.info("WebImageViewer started. Listening on " + address.toString() + ". Press Ctrl+C to stop the viewer."); }
protected ChannelPipelineFactory createServerPipelineFactory() { return new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("c2sVerifier", c2sVerifier); pipeline.addLast("throttleControl", new SendThrottle( s2cDataSender)); pipeline.addLast("sendStarter", new SimpleChannelUpstreamHandler() { @Override public void channelConnected( ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channel childChannel = e.getChannel(); channels.add(childChannel); s2cDataSender.setChannel(childChannel); executor.execute(s2cDataSender); } }); return pipeline; } }; }
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); final AirPlayServer airPlayServer = AirPlayServer.getIstance(); pipeline.addLast("executionHandler", airPlayServer.getChannelExecutionHandler()); pipeline.addLast("closeOnShutdownHandler", new SimpleChannelUpstreamHandler() { @Override public void channelOpen(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { airPlayServer.getChannelGroup().add(e.getChannel()); super.channelOpen(ctx, e); } }); pipeline.addLast("exceptionLogger", new ExceptionLoggingHandler()); pipeline.addLast("decoder", new RtspRequestDecoder()); pipeline.addLast("encoder", new RtspResponseEncoder()); pipeline.addLast("logger", new RtspLoggingHandler()); pipeline.addLast("errorResponse", new RtspErrorResponseHandler()); pipeline.addLast("challengeResponse", new RaopRtspChallengeResponseHandler(NetworkUtils.getInstance().getHardwareAddress())); pipeline.addLast("header", new RaopRtspHeaderHandler()); pipeline.addLast("options", new RaopRtspOptionsHandler()); pipeline.addLast("audio", new RaopAudioHandler(airPlayServer.getExecutorService())); pipeline.addLast("unsupportedResponse", new RtspUnsupportedResponseHandler()); return pipeline; }
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); final AirPlayServer airPlayServer = AirPlayServer.getIstance(context); pipeline.addLast("executionHandler", airPlayServer.getChannelExecutionHandler()); pipeline.addLast("closeOnShutdownHandler", new SimpleChannelUpstreamHandler() { @Override public void channelOpen(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { airPlayServer.getChannelGroup().add(e.getChannel()); super.channelOpen(ctx, e); } }); pipeline.addLast("exceptionLogger", new ExceptionLoggingHandler()); pipeline.addLast("decoder", new RtspRequestDecoder()); pipeline.addLast("encoder", new RtspResponseEncoder()); //pipeline.addLast("aggregator", new HttpChunkAggregator(655360));//buffer size pipeline.addLast("logger", new RtspLoggingHandler(context)); pipeline.addLast("errorResponse", new RtspErrorResponseHandler()); pipeline.addLast("challengeResponse", new RaopRtspChallengeResponseHandler(NetworkUtils.getInstance().getHardwareAddress())); pipeline.addLast("header", new RaopRtspHeaderHandler()); pipeline.addLast("options", new RaopRtspOptionsHandler()); pipeline.addLast("audio", new RaopAudioHandler(airPlayServer.getExecutorService(),context)); pipeline.addLast("unsupportedResponse", new RtspUnsupportedResponseHandler()); return pipeline; }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { configure(e); gameManager.getChannelUtils().write(playerId, "Thanks, COME AGAIN." + "\r\n", true); creeperSession.setGrabMerchant(Optional.<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>>empty()); e.getChannel().getPipeline().remove("executed_command"); e.getChannel().getPipeline().remove("executed_bank_command"); String s = gameManager.buildPrompt(playerId); write(s); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { configure(e); creeperSession.setGrabMerchant(Optional.<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>>empty()); player.setPlayerClass(playerClass); write("You are now and forever, a " + CreeperUtils.capitalize(playerClass.getIdentifier()) + "\r\n"); e.getChannel().getPipeline().remove("executed_command"); e.getChannel().getPipeline().remove("executed_playerclass_command"); String s = gameManager.buildPrompt(playerId); write(s); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { configure(e); creeperSession.setGrabMerchant(Optional.<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>>empty()); e.getChannel().getPipeline().remove("executed_command"); e.getChannel().getPipeline().remove("executed_playerclass_command"); String s = gameManager.buildPrompt(playerId); write(s); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { configure(e); creeperSession.setGrabMerchant(Optional.<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>>empty()); e.getChannel().getPipeline().remove("executed_command"); e.getChannel().getPipeline().remove("executed_locker_command"); String s = gameManager.buildPrompt(playerId); write(s); }
@Before public void setUp() throws Exception { upstreamMock = Mockito.mock(SimpleChannelUpstreamHandler.class, Answers.CALLS_REAL_METHODS.get()); ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("open-channels", queryChannelsRegistry); pipeline.addLast("delimiter", new DelimiterBasedFrameDecoder(1024, true, ChannelBuffers.wrappedBuffer(new byte[]{'\n'}))); pipeline.addLast("string-decoder", new StringDecoder(Charsets.UTF_8)); pipeline.addLast("whois-encoder", applicationContext.getBean(WhoisEncoder.class)); pipeline.addLast("exception", new ExceptionHandler()); pipeline.addLast("query-decoder", applicationContext.getBean(QueryDecoder.class)); pipeline.addLast("connection-state", new ConnectionStateHandler()); pipeline.addLast("upstreamMock", upstreamMock); when(whoisServerPipelineFactory.getPipeline()).thenReturn(pipeline); doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocationOnMock) throws Throwable { ResponseHandler responseHandler = (ResponseHandler) invocationOnMock.getArguments()[3]; responseHandler.handle(RpslObject.parse(queryResult)); return null; } }).when(queryHandler).streamResults(any(Query.class), any(InetAddress.class), anyInt(), any(ResponseHandler.class)); queryServer.start(); }
public SimpleUdpServer(int port, SimpleChannelUpstreamHandler program, int workerCount) { this.port = port; this.rpcProgram = program; this.workerCount = workerCount; }
public NettyClientPipelineFactory(SimpleChannelUpstreamHandler handler) { this.handler = handler; }
public NettyClientPipelineFactory(SimpleChannelUpstreamHandler handler){ this.handler = handler; }
public java.util.Optional<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>> getGrabMerchant() { return grabMerchant; }
public void setGrabMerchant(java.util.Optional<CreeperEntry<Merchant, SimpleChannelUpstreamHandler>> grabMerchant) { this.grabMerchant = grabMerchant; }