How to implement or use WebSocket in perl?

I need to have 3 basic things from perl and don't know how to do this.

  • A non-blocking implementation of websocket, for example mojo.
  • The server needs to receive broadcast calls after it starts.
  • The server must have access to data that is in another stream.

I tried mojo, but did not find a way to manage the port (I can live with it) and did not understand how to trigger events after the server starts. I could not verify if he could handle events after the fact.

I tried Net::WebSocket::Server, but it blocks. I am tempted to bundle my own code around it so that it can handle non-blocking and shared data, as it is by far the easiest implementation and is easy to modify.

I also tried it pocket.io, but it didn’t have a very easy way to implement OO design and still remain streaming. (Mainly because of the scope Plack).

Does anyone have a good example of how to do this with Mojoliciousor pocket.io? If not, I just need to implement my own implementation.

+4
source share

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


All Articles