/** * Sends a {@code "messageReceived"} event to the * {@link ChannelUpstreamHandler} which is placed in the closest upstream * from the handler associated with the specified * {@link ChannelHandlerContext}. * * @param message the received message */ public static void fireMessageReceived(ChannelHandlerContext ctx, Object message) { ctx.sendUpstream(new UpstreamMessageEvent(ctx.getChannel(), message, null)); }
@Override public String toString() { if (getRemoteAddress() == getChannel().getRemoteAddress()) { return getChannel().toString() + " RECEIVED: " + StringUtil.stripControlCharacters(getMessage()); } else { return getChannel().toString() + " RECEIVED: " + StringUtil.stripControlCharacters(getMessage()) + " from " + getRemoteAddress(); } } }
if (ume.getMessage() instanceof ChannelBuffer) { ChannelBuffer cb = (ChannelBuffer) ume.getMessage(); int readableBytes = cb.readableBytes();
public ChannelFuture getFuture() { return succeededFuture(getChannel()); }
/** * Sends a {@code "messageReceived"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} belongs. * * @param message the received message * @param remoteAddress the remote address where the received message * came from */ public static void fireMessageReceived(Channel channel, Object message, SocketAddress remoteAddress) { channel.getPipeline().sendUpstream( new UpstreamMessageEvent(channel, message, remoteAddress)); }
/** * Sends a {@code "messageReceived"} event to the * {@link ChannelUpstreamHandler} which is placed in the closest upstream * from the handler associated with the specified * {@link ChannelHandlerContext}. * * @param message the received message * @param remoteAddress the remote address where the received message * came from */ public static void fireMessageReceived( ChannelHandlerContext ctx, Object message, SocketAddress remoteAddress) { ctx.sendUpstream(new UpstreamMessageEvent( ctx.getChannel(), message, remoteAddress)); }
void fireMessageReceived(FileChannel fileChannel, ChannelAddress fileAddress) { MessageEvent msg = new UpstreamMessageEvent(fileChannel, fileChannel.readBuffer, fileAddress); fileChannel.getPipeline().sendUpstream(msg); }
new UpstreamMessageEvent(eventIn.getChannel(), messageDDF, null);
private void handleWebSocketFrame(ChannelHandlerContext ctx, Channel channel, WebSocketFrame frame) throws IOException { // Check for closing frame if (frame instanceof CloseWebSocketFrame) { handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame); return; } else if (frame instanceof PingWebSocketFrame) { ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData())); return; } else if (!(frame instanceof TextWebSocketFrame)) { throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass().getName())); } String request = ((TextWebSocketFrame) frame).getText(); logger.debug(String.format("Channel %s received '%s'", ctx.getChannel().getId(), request)); SockJsMessage jsMessage = new SockJsMessage(request); ctx.sendUpstream(new UpstreamMessageEvent(channel, jsMessage, channel.getRemoteAddress())); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { // lookup child channel based on local and remote addresses NioChildDatagramChannel childChannel = getChildChannel(e.getChannel(), e.getRemoteAddress()); UpstreamMessageEvent event = new UpstreamMessageEvent(childChannel, e.getMessage(), e.getRemoteAddress()); AbstractNioWorker childWorker = childChannel.getWorker(); // Queue child channel message event (as it needs to be run on child worker) childWorker.messageReceived(childChannel, event); }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt) throws Exception { /* Get audio channel from the enclosing RaopAudioHandler */ Channel audioChannel = null; synchronized(RaopAudioHandler.this) { audioChannel = m_audioChannel; } if ((m_audioChannel != null) && m_audioChannel.isOpen() && m_audioChannel.isReadable()) { audioChannel.getPipeline().sendUpstream(new UpstreamMessageEvent( audioChannel, evt.getMessage(), evt.getRemoteAddress()) ); } } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception { HttpRequest request = (HttpRequest)e.getMessage(); HttpMethod method = request.getMethod(); // if we are a post then we send upstream, otherwise we are just being prompted for a response. if (method.equals(HttpMethod.POST)) { MessageEvent event = new UpstreamMessageEvent(e.getChannel(), request.getContent(), e.getRemoteAddress()); ctx.sendUpstream(event); } // add a new response responses.put(new ResponseHolder(System.currentTimeMillis() + responseTime, new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK))); }
@Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { if (!(evt instanceof MessageEvent)) { ctx.sendUpstream(evt); return; } final MessageEvent e = (MessageEvent) evt; final Object originalMessage = e.getMessage(); final Object decodedMessage = decode(ctx, e.getChannel(), originalMessage); if (originalMessage == decodedMessage) ctx.sendUpstream(evt); else if (decodedMessage != null) ctx.sendUpstream(new UpstreamMessageEvent(ctx.getChannel(), decodedMessage, e.getRemoteAddress())); // Channels.fireMessageReceived(ctx, decodedMessage, e.getRemoteAddress()); }
@Override protected void handleUnexpectedEvent(ChannelHandlerContext ctx, ChannelEvent evt) { Channel channel = evt.getChannel(); MessageEvent msg = new UpstreamMessageEvent(channel, copiedBuffer("", UTF_8), channel.getRemoteAddress()); // We create a message with an empty string. We need make sure our decoders get the decoder Last call. messageReceived(ctx, msg, true); // If the above caused a completion we are done. Otherwise we still need to handle the unexpected event if (!getHandlerFuture().isDone()) { super.handleUnexpectedEvent(ctx, evt); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception { HttpResponse response = (HttpResponse)e.getMessage(); if (httpRequiresSessionId && !active) { Set<Cookie> cookieMap = cookieDecoder.decode(response.getHeader(HttpHeaders.Names.SET_COOKIE)); for (Cookie cookie : cookieMap) { if (cookie.getName().equals("JSESSIONID")) { cookieEncoder.addCookie(cookie); this.cookie = cookieEncoder.encode(); } } active = true; handShakeFuture.run(); } MessageEvent event = new UpstreamMessageEvent(e.getChannel(), response.getContent(), e.getRemoteAddress()); waitingGet = false; ctx.sendUpstream(event); }
ctx.sendUpstream(new UpstreamMessageEvent(channel, jsMessage, channel.getRemoteAddress()));
for (String message : messages) { SockJsMessage jsMessage = new SockJsMessage(message); ctx.sendUpstream(new UpstreamMessageEvent(e.getChannel(), jsMessage, e.getRemoteAddress()));