mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-05-26 06:24:05 +03:00
more documentation to send a WS message with VueX
more doc. this save my file today ;)
This commit is contained in:
@@ -142,6 +142,7 @@ export default new Vuex.Store({
|
||||
},
|
||||
mutations:{
|
||||
SOCKET_ONOPEN (state, event) {
|
||||
Vue.prototype.$socket = event.currentTarget
|
||||
state.socket.isConnected = true
|
||||
},
|
||||
SOCKET_ONCLOSE (state, event) {
|
||||
@@ -162,6 +163,13 @@ export default new Vuex.Store({
|
||||
state.socket.reconnectError = true;
|
||||
},
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
sendMessage: function(context, message) {
|
||||
.....
|
||||
Vue.prototype.$socket.send(message)
|
||||
.....
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user