The specific situation is as follows:
The original plan was that after the client successfully registered, the server would return a token to the client and bind the corresponding sid for this token. When there is a new message, the server will search for the sid based on the token and push the message.
Sounds easy, right? But the problem lies here: no matter how I record the sid, I cannot push the message correctly, and the client has no response. After trying various solutions, I had to give up torturing myself and throw the problem to V2EX, hoping that some experts could help solve it
not because I'm lazy.
However, today, hope appeared: a guru directly provided the solution code. Finally, the problem was solved, and I started to study the train of thought. With a quick glance, I found a huge mistake I made: the sid I obtained from the server belongs to the server, but I must first obtain the sid from the client and pass it to the server in order for the server to locate the client and send messages.
Although it was a rookie mistake, the problem that troubled me for several days was finally solved, and I can happily write bugs again. I can only say that V friends are amazing, but it seems that I still need to improve my coding skills, otherwise, next time I may not be so lucky to encounter someone willing to help.