2
0
mirror of https://github.com/tenrok/vue-native-websocket.git synced 2026-06-17 01:20:34 +03:00

Fixes for empty sub-protocol and missing action names (#8)

* 1. Fixed DOMException: Failed to construct 'WebSocket': The subprotocol '' is invalid. in Chrome when empty protocol arg passed in WS ctor.  2.  Action name was never being set/executed on incoming messages.

* upated docs
This commit is contained in:
Mark Macneil
2017-07-10 13:09:10 -03:00
committed by Nathan
parent 46e251dcbc
commit 55aa4a75aa
3 changed files with 12 additions and 3 deletions
+2 -1
View File
@@ -10,7 +10,7 @@ export default class {
connect (connectionUrl, opts = {}) {
let protocol = opts.protocol || ''
this.WebSocket = opts.WebSocket || new WebSocket(connectionUrl, protocol)
this.WebSocket = opts.WebSocket || (protocol === '' ? new WebSocket(connectionUrl) : new WebSocket(connectionUrl, protocol))
if (this.format === 'json') {
if (!('sendObj' in this.WebSocket)) {
this.WebSocket.sendObj = (obj) => this.WebSocket.send(JSON.stringify(obj))
@@ -37,6 +37,7 @@ export default class {
target = [msg.namespace || '', msg.mutation].filter((e) => !!e).join('/')
if (msg.action) {
method = 'dispatch'
target = msg.action
}
}
this.store[method](target, msg)