Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible for namespace methods to return Futures of flows? #11

Open
mrwillis opened this issue May 21, 2018 · 0 comments
Open

Possible for namespace methods to return Futures of flows? #11

mrwillis opened this issue May 21, 2018 · 0 comments

Comments

@mrwillis
Copy link

mrwillis commented May 21, 2018

Hi,

I find myself sometimes asking another Actor to produce a Flow for me. For instance, this is used heavily in this example: https://github.com/playframework/play-scala-websocket-example (native websockets). In this case, the method requires you to return a Future[Flow]:

  /**
   * Creates an action that will either accept the websocket, using the given flow to handle the in and out stream, or
   * return a result to reject the Websocket.
   */
  def acceptOrResult[In, Out](f: RequestHeader => Future[Either[Result, Flow[In, Out, _]]])(implicit transformer: MessageFlowTransformer[In, Out]): WebSocket = {
    WebSocket { request =>
      f(request).map(_.right.map(transformer.transform))
    }
  }

Is it possible to use a similar pattern in this library or is it not relevant?

My other question is that is it possible to do some clean up actions? Something like onDisconnect?

Thanks for this library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant