3 ms·
I'm assuming that the Iteratee companion object uses implicits to get the client connection. I'd really prefer something more explicit like socket.io's approach
by axelf 13y ago
I'm assuming that the Iteratee companion object uses implicits to get the client connection. I'd really prefer something more explicit like socket.io's approach.
- saryant 13y agoThat assumption is incorrect. Implicits are not used here (for that purpose anyways). The client connection is handled by that "WebSocket.using[String]" handler. This is just a function that takes a function which takes a Request and returns an Iteratee and an Enumerator. In Play, this is known as an Action. Actions take Requests and return Results. You can see that in the type signature of the WebSocket class: http://www.playframework.com/documentation/2.2.x/api/scala/index.html#play.api.mvc.WebSocket http://www.playframework.com/documentation/2.2.x/api/scala/i... (f: (RequestHeader) ⇒ (Enumerator[A], Iteratee[A, Unit]) ⇒ Unit) So the client connection is not bound using implicits, it's bound when that function is actually executed. This function (f) is invoked by the router when a request comes in for that controller action. This is done using HandlerInvoker: http://www.playframework.com/documentation/2.2.x/api/scala/index.html#play.core.Router$$HandlerInvoker http://www.playframework.com/documentation/2.2.x/api/scala/i... Now, my explanation is not the most eloquent nor is it really necessary to understand all of this, though it certainly helps.