Calling a method in play WebSocket in Scala

后端 未结 1 2008
逝去的感伤
逝去的感伤 2021-01-26 17:25

I am new to scala, Play framework and Akka. I have function defined as

def socket = WebSocket.accept[String, String] { request =>
    ActorFlow.actorRef(out =         


        
相关标签:
1条回答
  • 2021-01-26 17:57

    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 a Controller.

    def anotherControllerAction = objectName.socket

    That would basically just point anotherControllerAction to the socket implementation. Then you still need to put anotherControllerAction into your routes file.

    You might want to describe in more detail, what you actually want to achieve

    0 讨论(0)
提交回复
热议问题