I am new to scala, Play framework and Akka. I have function defined as
def socket = WebSocket.accept[String, String] { request =>
ActorFlow.actorRef(out => MyWebSocketActor.props(out))
}
This i want to call from other class .I am not clear how to call this function as, i can't call this by
objectName.socket(implict req:RequestHeader)
I am working in Play 2.5.3 , Scala 2.11.7 and Akka 2.4.7 .
Edit: it gives me error : '=>' expected, ')' found
I'm still not sure, what the benefit of that would be, but I'll try to answer your question.
First of all, this (
objectName.socket(implict req:RequestHeader)
) ist not how you call a method with an implicit parameter (also you have a typo there in implicit).But as you already pointed out correctly, you need an implicit
RequestHeader
, so you only can call this method within the context of aController
.def anotherControllerAction = objectName.socket
That would basically just point
anotherControllerAction
to the socket implementation. Then you still need to putanotherControllerAction
into your routes file.You might want to describe in more detail, what you actually want to achieve