mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-18 22:20:34 +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:{
|
mutations:{
|
||||||
SOCKET_ONOPEN (state, event) {
|
SOCKET_ONOPEN (state, event) {
|
||||||
|
Vue.prototype.$socket = event.currentTarget
|
||||||
state.socket.isConnected = true
|
state.socket.isConnected = true
|
||||||
},
|
},
|
||||||
SOCKET_ONCLOSE (state, event) {
|
SOCKET_ONCLOSE (state, event) {
|
||||||
@@ -162,6 +163,13 @@ export default new Vuex.Store({
|
|||||||
state.socket.reconnectError = true;
|
state.socket.reconnectError = true;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
sendMessage: function(context, message) {
|
||||||
|
.....
|
||||||
|
Vue.prototype.$socket.send(message)
|
||||||
|
.....
|
||||||
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user