/** * Sends a {@code "messageReceived"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param message the received message */ public static void fireMessageReceived(Channel channel, Object message) { fireMessageReceived(channel, message, null); }
public void readSettingsEnd() { Object frame = spdySettingsFrame; spdySettingsFrame = null; Channels.fireMessageReceived(ctx, frame); }
protected final void unfoldAndFireMessageReceived( ChannelHandlerContext context, SocketAddress remoteAddress, Object result) { if (unfold) { if (result instanceof Object[]) { for (Object r: (Object[]) result) { Channels.fireMessageReceived(context, r, remoteAddress); } } else if (result instanceof Iterable<?>) { for (Object r: (Iterable<?>) result) { Channels.fireMessageReceived(context, r, remoteAddress); } } else { Channels.fireMessageReceived(context, result, remoteAddress); } } else { Channels.fireMessageReceived(context, result, remoteAddress); } }
public void readGoAwayFrame(int lastGoodStreamId, int statusCode) { SpdyGoAwayFrame spdyGoAwayFrame = new DefaultSpdyGoAwayFrame(lastGoodStreamId, statusCode); Channels.fireMessageReceived(ctx, spdyGoAwayFrame); }
public void readPingFrame(int id) { SpdyPingFrame spdyPingFrame = new DefaultSpdyPingFrame(id); Channels.fireMessageReceived(ctx, spdyPingFrame); }
public void readRstStreamFrame(int streamId, int statusCode) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, statusCode); Channels.fireMessageReceived(ctx, spdyRstStreamFrame); }
public void readWindowUpdateFrame(int streamId, int deltaWindowSize) { SpdyWindowUpdateFrame spdyWindowUpdateFrame = new DefaultSpdyWindowUpdateFrame(streamId, deltaWindowSize); Channels.fireMessageReceived(ctx, spdyWindowUpdateFrame); }
public boolean offer(Object input) { fireMessageReceived(getChannel(), input); return !isEmpty(); } }
public void readHeaderBlockEnd() { Object frame = null; try { spdyHeaderBlockDecoder.endHeaderBlock(spdyHeadersFrame); frame = spdyHeadersFrame; spdyHeadersFrame = null; } catch (Exception e) { Channels.fireExceptionCaught(ctx, e); } if (frame != null) { Channels.fireMessageReceived(ctx, frame); } }
public void readDataFrame(int streamId, boolean last, ChannelBuffer data) { SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamId); spdyDataFrame.setLast(last); spdyDataFrame.setData(data); Channels.fireMessageReceived(ctx, spdyDataFrame); }
@Override boolean process() throws IOException { byte[] buf; int readBytes; PushbackInputStream in = channel.getInputStream(); int bytesToRead = in.available(); if (bytesToRead > 0) { buf = new byte[bytesToRead]; readBytes = in.read(buf); } else { int b = in.read(); if (b < 0) { return false; } in.unread(b); return true; } fireMessageReceived(channel, channel.getConfig().getBufferFactory().getBuffer(buf, 0, readBytes)); return true; }
public void handleUpstream( ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { if (!(evt instanceof MessageEvent)) { ctx.sendUpstream(evt); return; } MessageEvent e = (MessageEvent) evt; Object originalMessage = e.getMessage(); Object decodedMessage = decode(ctx, e.getChannel(), originalMessage); if (originalMessage == decodedMessage) { ctx.sendUpstream(evt); } else if (decodedMessage != null) { fireMessageReceived(ctx, decodedMessage, e.getRemoteAddress()); } }
Channels.fireMessageReceived(ctx, coordinatorRequest);
@Override boolean process() throws IOException { ReceiveBufferSizePredictor predictor = channel.getConfig().getReceiveBufferSizePredictor(); byte[] buf = new byte[predictor.nextReceiveBufferSize()]; DatagramPacket packet = new DatagramPacket(buf, buf.length); try { channel.socket.receive(packet); } catch (InterruptedIOException e) { // Can happen on interruption. // Keep receiving unless the channel is closed. return true; } fireMessageReceived( channel, channel.getConfig().getBufferFactory().getBuffer(buf, 0, packet.getLength()), packet.getSocketAddress()); return true; }
/** * Replace this {@link FrameDecoder} in the {@link ChannelPipeline} with the given {@link ChannelHandler}. All * remaining bytes in the {@link ChannelBuffer} will get send to the new {@link ChannelHandler} that was used * as replacement * */ public void replace(String handlerName, ChannelHandler handler) { if (ctx == null) { throw new IllegalStateException( "Replace cann only be called once the FrameDecoder is added to the ChannelPipeline"); } ChannelPipeline pipeline = ctx.getPipeline(); pipeline.addAfter(ctx.getName(), handlerName, handler); try { if (cumulation != null) { Channels.fireMessageReceived(ctx, cumulation.readBytes(actualReadableBytes())); } } finally { pipeline.remove(this); } }
private void issueStreamError( ChannelHandlerContext ctx, SocketAddress remoteAddress, int streamId, SpdyStreamStatus status) { boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamId); ChannelFuture future = Channels.future(ctx.getChannel()); removeStream(streamId, future); SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status); Channels.write(ctx, future, spdyRstStreamFrame, remoteAddress); if (fireMessageReceived) { Channels.fireMessageReceived(ctx, spdyRstStreamFrame, remoteAddress); } }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (!readingChunks) { HttpResponse res = (HttpResponse) e.getMessage(); if (res.getStatus().getCode() != HttpResponseStatus.OK.getCode()) { throw new ChannelException("Unexpected HTTP response status: " + res.getStatus()); } if (res.isChunked()) { readingChunks = true; } else { ChannelBuffer content = res.getContent(); if (content.readable()) { fireMessageReceived(HttpTunnelingClientSocketChannel.this, content); } // Reached to the end of response - close the request. closeReal(succeededFuture(virtualChannel)); } } else { HttpChunk chunk = (HttpChunk) e.getMessage(); if (!chunk.isLast()) { fireMessageReceived(HttpTunnelingClientSocketChannel.this, chunk.getContent()); } else { readingChunks = false; // Reached to the end of response - close the request. closeReal(succeededFuture(virtualChannel)); } } }
store, parseZoneId()); Channels.fireMessageReceived(ctx, voldemortStoreRequest); } else { logger.error("Error when getting store. Non Existing store name.");
Channels.fireMessageReceived(ctx, msg, event.getRemoteAddress());
Channels.fireMessageReceived(ctx, msg, event.getRemoteAddress());