added ability to switch faster between sessions using query parameters and added option to switch between localhost and server
parent
a40d6a769b
commit
79ef8afd89
|
@ -1,16 +1,30 @@
|
||||||
let ws = null
|
/* DEFINITIONS */
|
||||||
|
|
||||||
let wsPort = 3000
|
|
||||||
let wsAddress = "ws://localhost:"
|
|
||||||
//let wsAddress = "wss://alpha-ws.clickandjoin.umbach.dev"
|
|
||||||
|
|
||||||
let sseAddress = "http://127.0.0.1:3005/"
|
|
||||||
//let sseAddress = "https://alpha-sse.clickandjoin.umbach.dev/"
|
|
||||||
|
|
||||||
|
const localhost = true
|
||||||
const sseEnabled = false
|
const sseEnabled = false
|
||||||
const wssEnabled = true
|
const wssEnabled = true
|
||||||
|
|
||||||
|
let wsPort = 3000
|
||||||
|
let wsAddressLocal = "ws://localhost:"
|
||||||
|
const wsAddressServer = "wss://alpha-ws.clickandjoin.umbach.dev"
|
||||||
|
|
||||||
|
const sseAddressLocal = "http://127.0.0.1:3005/"
|
||||||
|
const sseAddressServer = "https://alpha-sse.clickandjoin.umbach.dev/"
|
||||||
|
|
||||||
|
/* DEFINITIONS END */
|
||||||
|
|
||||||
|
let ws = null
|
||||||
|
let sseAddress, wsAddress = "";
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
|
if (localhost) {
|
||||||
|
sseAddress = sseAddressLocal
|
||||||
|
wsAddress = wsAddressLocal
|
||||||
|
} else {
|
||||||
|
sseAddress = sseAddressServer
|
||||||
|
wsAddress = wsAddressServer
|
||||||
|
}
|
||||||
|
|
||||||
const msg = document.getElementById("msg")
|
const msg = document.getElementById("msg")
|
||||||
const receiver = document.getElementById("receiver")
|
const receiver = document.getElementById("receiver")
|
||||||
|
|
||||||
|
@ -36,11 +50,7 @@ window.onload = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("change-ws").onclick = () => {
|
document.getElementById("change-ws").onclick = () => {
|
||||||
if (wsPort === 3000) {
|
wsPort === 3000 ? wsPort = 3001 : wsPort = 3000
|
||||||
wsPort = 3001
|
|
||||||
} else {
|
|
||||||
wsPort = 3000
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ws.readyState == 1) {
|
if (ws.readyState == 1) {
|
||||||
ws.close()
|
ws.close()
|
||||||
|
@ -65,10 +75,28 @@ function connectSSE() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let auths = [
|
||||||
|
"WAZgOGzc-g5VC-zbav-KxCT-bCNlFfQk6ptl",
|
||||||
|
"AdZ23xwZ-EhNl-vbbh-I3j3-BlCqsSRYjRM5",
|
||||||
|
"yq2DjCWN-wdtj-pPRx-CAfL-YbfDb113nEIX",
|
||||||
|
"cKagUAi2-y0jf-uWax-kDj5-rMOnwl41TA8l",
|
||||||
|
"hKJrICzW-fgw1-kgUw-k7hG-2de2rroaXEo3",
|
||||||
|
"z8NJ0VOw-U35X-Yl3W-tusq-MbS2coW2eQRi"]
|
||||||
|
|
||||||
function connectWS() {
|
function connectWS() {
|
||||||
if (!wssEnabled) return
|
if (!wssEnabled) return
|
||||||
|
|
||||||
ws = new WebSocket(wsAddress + wsPort + "/?auth=sMURqnQt-88Ko-SaWu-2GLr-K2iQECXDyONm")
|
let s = parseInt(window.location.search.split("=")[1]) // ?s=NUMBER_OF_PREFERED_WS_SESSION
|
||||||
|
|
||||||
|
let auth;
|
||||||
|
|
||||||
|
s == undefined || s > (auths.length - 1) ? auth = auths[0] : auth = auths[s]
|
||||||
|
|
||||||
|
if (localhost) {
|
||||||
|
wsAddress = wsAddressLocal + wsPort
|
||||||
|
}
|
||||||
|
|
||||||
|
ws = new WebSocket(wsAddress + "/?auth=" + auth)
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
console.info("ws open", document.getElementById("userid"))
|
console.info("ws open", document.getElementById("userid"))
|
||||||
|
|
Loading…
Reference in New Issue