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:
+2
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user