The title is not clear enough, and then the details are explained below.
A message that the user needs to receive.
One is in the server based on the last operation to determine the state, such as whether the Chat window is open, and then according to the status of sending different messages, such as the Chat window opened to send chat messages, if not open, send a message prompt.
The other is the server sends a message, and then a user receives after the use of JS to determine whether the window is open and then select the prompt or display.
I think the first way to the information of a higher degree of control, and the server computer than the client's good, can guarantee the integrity of the information. But if the state gets the wrong thing, it's going to get messed up.
The second way is easy to write, but is not a user-side experience is not very good, after all, to do logical processing.
The service-side code is written on the basis of Wokerman, and should not be relevant to this issue.
Or is there any other better way? I hope our predecessors will not hesitate to enlighten. Thank you, sir.
Reply content:
The title is not clear enough, and then the details are explained below.
A message that the user needs to receive.
One is in the server based on the last operation to determine the state, such as whether the Chat window is open, and then according to the status of sending different messages, such as the Chat window opened to send chat messages, if not open, send a message prompt.
The other is the server sends a message, and then a user receives after the use of JS to determine whether the window is open and then select the prompt or display.
I think the first way to the information of a higher degree of control, and the server computer than the client's good, can guarantee the integrity of the information. But if the state gets the wrong thing, it's going to get messed up.
The second way is easy to write, but is not a user-side experience is not very good, after all, to do logical processing.
The service-side code is written on the basis of Wokerman, and should not be relevant to this issue.
Or is there any other better way? I hope our predecessors will not hesitate to enlighten. Thank you, sir.
Send the original message to the front-end for processing, this processing does not affect the user experience