Class WebSocketEvent

java.lang.Object
com.mastfrog.acteur.server.WebSocketEvent
All Implemented Interfaces:
Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>

public final class WebSocketEvent extends Object implements Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
Author:
Tim Boudreau
  • Constructor Details

    • WebSocketEvent

      public WebSocketEvent(io.netty.handler.codec.http.websocketx.WebSocketFrame frame, io.netty.channel.ChannelHandlerContext channel, SocketAddress addr, Codec mapper)
  • Method Details

    • channel

      public io.netty.channel.Channel channel()
      Description copied from interface: Event
      Get the Netty channel this request is travelling through.
      Specified by:
      channel in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
      Returns:
      The channel
    • ctx

      public io.netty.channel.ChannelHandlerContext ctx()
      Specified by:
      ctx in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
    • request

      public io.netty.handler.codec.http.websocketx.WebSocketFrame request()
      Description copied from interface: Event
      Get the actual HTTP request.
      Specified by:
      request in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
      Returns:
      An http request
    • remoteAddress

      public SocketAddress remoteAddress()
      Description copied from interface: Event
      Get the remote address of whoever made the request. The framework will take care of interpreting HTTP headers used by proxies to represent the real origin.
      Specified by:
      remoteAddress in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
      Returns:
      An address
    • jsonContent

      public <T> T jsonContent(Class<T> type) throws IOException
      Description copied from interface: Event
      Will use Jackson to parse the request body and return an object of the type requested if possible.

      Specified by:
      jsonContent in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
      Type Parameters:
      T - The type
      Parameters:
      type - The type of object to return
      Returns:
      An object of type T
      Throws:
      IOException - if the body is malformed or for some other reason, cannot be parsed
    • content

      public io.netty.buffer.ByteBuf content() throws IOException
      Description copied from interface: Event
      Get the raw request body, if any.
      Specified by:
      content in interface Event<io.netty.handler.codec.http.websocketx.WebSocketFrame>
      Returns:
      A bytebuf if one is available.
      Throws:
      IOException - If something goes wrong