org.mashupbots.socko.events

WebSocketHandshakeEvent

case class WebSocketHandshakeEvent(context: ChannelHandlerContext, nettyHttpRequest: FullHttpRequest, config: HttpEventConfig) extends SockoEvent with HttpEvent with Product with Serializable

Event fired when performing a web socket handshake to upgrade a HTTP connection to a web socket connection.

Socko requires this event be processed in your route and NOT passed to actors. The only action that needs to be taken is to call event.authorize().

val routes = Routes({
  case event @ Path("/snoop/websocket/") => event match {
    case event: WebSocketHandshakeEvent => {
      event.authorize()
    }
    case event: WebSocketFrameEvent => {
      myActorSystem.actorOf(Props[MyWebSocketFrameProcessor], name) ! event
    }
  }
})

Calling event.authorize() authorizes Socko to perform all the necessary handshaking. If not called, Socko will reject the handshake and web sockets processing will be aborted.

event.authorize() is a security measure to ensure that upgrades to web socket connections is only performed at explicit routes.

nettyHttpRequest

HTTP request associated with the upgrade to web sockets connection

config

Processing configuration

Linear Supertypes
Serializable, Serializable, Product, Equals, HttpEvent, SockoEvent, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. WebSocketHandshakeEvent
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. HttpEvent
  7. SockoEvent
  8. AnyRef
  9. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new WebSocketHandshakeEvent(context: ChannelHandlerContext, nettyHttpRequest: FullHttpRequest, config: HttpEventConfig)

    nettyHttpRequest

    HTTP request associated with the upgrade to web sockets connection

    config

    Processing configuration

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def authorize(subprotocols: String = "", maxFrameSize: Int = 102400, onComplete: Option[(String) ⇒ Unit] = None, onClose: Option[(String) ⇒ Unit] = None): Unit

    Authorize this web socket handshake to proceed

    Authorize this web socket handshake to proceed

    maxFrameSize

    Maximum size of web socket frames. Defaults to 100K.

    onComplete

    Optional callback executed when the handshake is successfully completed. You can use this callback to register the web socket client as being ready to receive data.

    onClose

    Optional callback executed when the websocket is closed. The closed web socket id is passed to method

  8. def authorizedSubprotocols: String

    Comma separated list of supported protocols.

    Comma separated list of supported protocols. e.g. chat, stomp

  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. val config: HttpEventConfig

    Processing configuration

    Processing configuration

    Definition Classes
    WebSocketHandshakeEventHttpEvent
  11. val context: ChannelHandlerContext

    Netty channel associated with this request

    Netty channel associated with this request

    Definition Classes
    WebSocketHandshakeEventSockoEvent
  12. val createdOn: Date

    Timestamp when this event was fired

    Timestamp when this event was fired

    Definition Classes
    SockoEvent
  13. def duration(): Long

    Number of milliseconds from the time when this context was created

    Number of milliseconds from the time when this context was created

    Definition Classes
    SockoEvent
  14. val endPoint: EndPoint

    HTTP end point

    HTTP end point

    Definition Classes
    WebSocketHandshakeEventSockoEvent
  15. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def isAuthorized: Boolean

    Indicates if this web socket handshake is authorized or not

  19. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  20. lazy val items: Map[String, Any]

    Store of items that can be used to pass data from route to processor and between processors.

    Store of items that can be used to pass data from route to processor and between processors.

    This map is not synchronized and not thread-safe. In most cases, we expect this cache to be used by a single thread - hence a standard map is faster.

    If you do need to use a thread safe map, from your route, instance and store a ConcurrentHashMap as an item in this cache.

    Definition Classes
    SockoEvent
  21. def maxFrameSize: Int

    Maximum size of frames for this web socket connection in bytes.

  22. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. val nettyHttpRequest: FullHttpRequest

    HTTP request associated with the upgrade to web sockets connection

  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. def onClose: Option[(String) ⇒ Unit]

    Callback for when the web socket is closed

  27. def onComplete: Option[(String) ⇒ Unit]

    Callback for when the handshake as completed

  28. val request: CurrentHttpRequestMessage

    Incoming HTTP request

  29. val response: Null

    Always s set to null because no response is available for handshakes.

    Always s set to null because no response is available for handshakes. Let the handshaker do the work for you.

  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  31. var username: Option[String]

    Username of the authenticated user.

    Username of the authenticated user. You need to set this for it to appear in the web logs.

    Socko does not make assumptions on your authentication method. You do it and set this username to let us know.

    Definition Classes
    SockoEvent
  32. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. val webSocketId: String

    Unique ID for this web socket connection

    Unique ID for this web socket connection

    With Netty 5, we can use ChannelId. However, this is not supported in Netty 4 so we'll have to use a combination of the UUID and the object hash code.

  36. def writeWebLog(responseStatusCode: Int, responseSize: Long): Unit

    Adds an entry to the web log

    Adds an entry to the web log

    responseStatusCode

    HTTP status code

    responseSize

    length of response content in bytes

    Definition Classes
    WebSocketHandshakeEventHttpEvent

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from HttpEvent

Inherited from SockoEvent

Inherited from AnyRef

Inherited from Any

Ungrouped