problem description
the company currently needs to use the customer service chat function. It uses vue+element to manage the background. The actual situation is as follows:
- at present, an API with ws protocol in the background can connect
websocketto chat. The background interface is similar to this:ws://host/chat?id=xx&page=x&limit=xxwherepageis the page number parameter, andlimitgets the number of messages per page. That means I can passpageandlimitto get previous chat records - I am calling the
ws protocolinterface in thecreatehook function, starting withpage=1,limit=10, and then scrolling up to the top to changepage=page+1to continue to requestws protocolinterface.
problems
am I doing the right thing? Because in this way, every time I scroll to the top, I will create a new websocket connection, and whenever I finish getting the message record, I have to close this websocket connection immediately, and if there is a new message coming, both websocket connections will push the message to me, and a message will be repeated twice, right?
places to ask for advice
I don"t know if you have made similar requirements, how to solve them, and do you want to save the chat records at the front end? Where is the right place to exist, how much data can the browser store, and which storage is better? Thank you in advance here
