The title is not clear enough, please explain in detail.
A user needs to receive messages.
One is to determine the status on the server based on the last operation, such as whether the chat window is open, and then send different messages according to the status. For example, if the chat window is open, it will send a chat message, if it is not open, it will send a message prompt.
The other is that the server sends a message, and then after receiving it, user A uses JS to determine whether the window is open and then chooses whether to prompt or display.
I think the first method has a higher degree of control over the information, and the server computer is better than the client computer to ensure the integrity of the information. But if there is an error in obtaining the status, everything will go wrong.
The second way is more convenient to write, but the user experience will not be good, after all, it needs to be logically processed.
The server-side code is written based on wokerman, and it should not be very relevant to this problem.
Or is there any other better way? I hope the seniors will give me some advice. Thank you.
The title is not clear enough, please explain in detail.
A user needs to receive messages.
One is to determine the status on the server based on the last operation, such as whether the chat window is open, and then send different messages according to the status. For example, if the chat window is open, it will send a chat message, if it is not open, it will send a message prompt.
The other is that the server sends a message, and then after receiving it, user A uses JS to determine whether the window is open and then chooses whether to prompt or display.
I think the first method has a higher degree of control over the information, and the server computer is better than the client computer to ensure the integrity of the information. But if there is an error in obtaining the status, everything will go wrong.
The second way is more convenient to write, but the user experience will not be good, after all, it needs to be logically processed.
The server-side code is written based on wokerman, and it should not be very relevant to this problem.
Or is there any other better way? I hope the seniors will give me some advice. Thank you.
Send the original message to the front end for processing. This processing will not affect the user experience