mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-23 01:50:35 +03:00
Updated manual connect to accept alternative connection
Updated manual connect to accept alternative connection
This commit is contained in:
@@ -67,7 +67,10 @@ Vue.use(VueNativeSock, 'ws://localhost:9090', {
|
|||||||
connectManually: true,
|
connectManually: true,
|
||||||
})
|
})
|
||||||
const vm = new Vue()
|
const vm = new Vue()
|
||||||
|
// Connect to the websocket target specified in the configuration
|
||||||
vm.$connect()
|
vm.$connect()
|
||||||
|
// Connect to an alternative websocket URL and Options e.g.
|
||||||
|
vm.$connect('ws://localhost:9090/alternative/connection/', { format: 'json' })
|
||||||
// do stuff with WebSockets
|
// do stuff with WebSockets
|
||||||
vm.$disconnect()
|
vm.$disconnect()
|
||||||
```
|
```
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opts.connectManually) {
|
if (opts.connectManually) {
|
||||||
Vue.prototype.$connect = () => {
|
Vue.prototype.$connect = (connectionUrl = connection, connectionOpts = opts) => {
|
||||||
observer = new Observer(connection, opts)
|
observer = new Observer(connectionUrl, connectionOpts)
|
||||||
Vue.prototype.$socket = observer.WebSocket
|
Vue.prototype.$socket = observer.WebSocket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user