javascript - Using the ws module of node.js to continuously send messages to the client, how should we continuously trigger the "send" action?
我想大声告诉你
我想大声告诉你 2017-05-16 13:26:33
0
2
524

The application scenario is relatively complex. To put it simply, it is the monitoring of chat records in a game, but it involves two servers:

1. The server on the game side establishes a websocket with the node.js server on my side, and the game side continuously pushes it to our node.js client.

2. The node.js server on my side needs to push the new chat information on the game side, store the chat information in the database, and then forward the chat information to the client (here is another one on my side) The node.js server and the websocket established by my front end)

3. NowThe problem isAfter my node.js server receives the chat information pushed from the game, I don’t know how to trigger the connection between my node.js server and the front-end. websocket to send information to the front end.

4. The previous method of using serInterval polling was very frustrating, but later I thought that emit could trigger the message, but I don’t know what should be used to trigger it. I hope the experts can give me some advice.

我想大声告诉你
我想大声告诉你

reply all(2)
仅有的幸福

After the websocket connection is established, the message event will be automatically triggered every time data arrives. Within this callback function, emit the monitored event to handle the client's needs. There is no problem in your picture. .

伊谢尔伦

Broadcast

https://github.com/websockets...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!