TCP socket and web socket on playframework server?

My service already uses Websockets to communicate with the HTML5 client in a browser. The client is served by the same server from a regular HTTP request.

Now I would like to offer the same service / application, but from a browser, and I would like to offer it through TCP sockets.

The RPC / action object that I use will be the same, the serialization will be the same, the logic will be the same. I just want to use a TCP socket instead of a WebSocket.

I would like to save the code together in the same "project folder", starting from the moment the playframework server is deployed (basically at the start I want to start listening to WebSockets, TCP sockets and http requests) and all in one package when deployed.

I know that:

  • This is not necessary since WebSocket can be used in applications other than the browser, but consider this exercise or a question of curiosity.
  • playframework is built on top of netty, and I used netty before to do some TCP services (nothing big and nothing ready, though ... so not an expert). So they have to work together?

What I was going to do:

  • Ask the Akker to listen for new juice connections.
  • Wrap connections (WS or TCP sockets) in a ClientConnectionManager instance
  • Pass it on to actors who care about / rpc connection logic.

Other findings I reviewed: Re-executing the playframework controller class.

Or is there an already implemented solution for this?

+6
source share

Source: https://habr.com/ru/post/951457/


All Articles