Prompt for Websocket URI on page load until we get one.
This commit is contained in:
parent
0c16448d43
commit
3f9c07f48b
1 changed files with 23 additions and 0 deletions
23
src/main.js
23
src/main.js
|
|
@ -1,6 +1,29 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
import VueSocketIO from 'vue-socket.io';
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
|
let qs = new URLSearchParams(window.location.search);
|
||||||
|
let ws_uri;
|
||||||
|
if (qs.get(`ws-uri`)) {
|
||||||
|
ws_uri = qs.get(`ws-uri`)
|
||||||
|
if (!ws_uri.match(/^(wss?|https?):\/\//)) {
|
||||||
|
ws_uri = `ws://${ws_uri}`;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
ws_uri = ``
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:8080/?ws-uri=localhost:3000
|
||||||
|
|
||||||
|
while (ws_uri.length == 0 || !ws_uri.match(/^(wss?|https?):\/\//)) {
|
||||||
|
ws_uri = prompt("Input a websocket URI to connect to");
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.use(new VueSocketIO({
|
||||||
|
debug: true,
|
||||||
|
connection: ws_uri
|
||||||
|
}))
|
||||||
|
|
||||||
new Vue({render: h => h(App)}).$mount('#app');
|
new Vue({render: h => h(App)}).$mount('#app');
|
||||||
Loading…
Add table
Add a link
Reference in a new issue