diff --git a/README.md b/README.md index 7ced2a9..84864f3 100755 --- a/README.md +++ b/README.md @@ -67,7 +67,10 @@ Vue.use(VueNativeSock, 'ws://localhost:9090', { connectManually: true, }) const vm = new Vue() +// Connect to the websocket target specified in the configuration 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 vm.$disconnect() ``` diff --git a/src/Main.js b/src/Main.js index 53ab66d..dffa89b 100755 --- a/src/Main.js +++ b/src/Main.js @@ -13,8 +13,8 @@ export default { } if (opts.connectManually) { - Vue.prototype.$connect = () => { - observer = new Observer(connection, opts) + Vue.prototype.$connect = (connectionUrl = connection, connectionOpts = opts) => { + observer = new Observer(connectionUrl, connectionOpts) Vue.prototype.$socket = observer.WebSocket }