Processing of websocket in vue

current projects use vue, and native websocket. After logging in to the business, I use a unified js file as the entry for processing websocket, including websocket creation, connection, and message processing. I thought the message I was dealing with was simple. Now I find that I need to use the websocket object of new at login in the component, and then I use vuex as the storage. But I"m worried that the business of vuex"s websocket fetched in the business component will override the onmessage method. It turns out that part of the business is written in the entry and about the onmessage method, but it is not possible to handle all the business in the js of the websocket entry. So it"s annoying. Ask whether writing the onmessage method in the component will overwrite the original, and do you have any experience or methods to deal with it?

Mar.18,2021

is there any good solution? if it is the same websock object from return, it will be overwritten


excuse me whether the problem has been solved, I am also the same problem


Does

mean that it will be overwritten repeatedly when other components use onmessage?
such as

A.vue
socket.onmessage= function(event){
 A.vue...
}

B.vue
socket.onmessage= function(event){
 B.vue...
}
Will

B overwrite A?
if this is the case, wouldn't it be nice to write onmessage as the same? The name of the event is given with the cooperation of the background.
socket.onmessage= function (event) {

 if(event.Name == 'A.vue'){
  ...
 }else if(event.Name = '..'){
  ...
 }

}
I don't know if I understand it correctly.


does the landlord have a solution? Share

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4949e-44d36.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4949e-44d36.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?