Created
April 2, 2015 14:55
-
-
Save dat-vikash/ae2d3183e28588cdf82d to your computer and use it in GitHub Desktop.
Play 2.2.x WSClientVisitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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