Skip to content

Instantly share code, notes, and snippets.

@dat-vikash
Created April 2, 2015 14:55
Show Gist options
  • Save dat-vikash/ae2d3183e28588cdf82d to your computer and use it in GitHub Desktop.
Save dat-vikash/ae2d3183e28588cdf82d to your computer and use it in GitHub Desktop.
Play 2.2.x WSClientVisitor
// define our events
case class RegisterSocket()
case class Connected(out: Enumerator[JsValue], ref: ActorRef)
class WSClientVisitor(name: String) extends Actor with ActorLogging with WebSocketChannel
{
def receive = {
case RegisterSocket => {
// close over sender
val myClient = sender
// establish connection
myClient ! Connected(out,self)
// send a test message
push(Json.obj("type" -> "event", “data” -> “connection_on”))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment