fixed connect() not actually changing server hosts
This commit is contained in:
parent
c69d0bd891
commit
178313ec2b
|
@ -91,7 +91,7 @@ to help you feel a little more comfortable, i've prepared some commands for you:
|
||||||
* closes any existing websocket connection and attempts to create a new one.
|
* closes any existing websocket connection and attempts to create a new one.
|
||||||
* @param {string} server_url - the server websocket url to connect to.
|
* @param {string} server_url - the server websocket url to connect to.
|
||||||
*/
|
*/
|
||||||
export async function connect(url) {
|
export async function connect(server_url) {
|
||||||
if (client && client.readyState == 1) { // OPEN
|
if (client && client.readyState == 1) { // OPEN
|
||||||
client.close();
|
client.close();
|
||||||
|
|
||||||
|
@ -144,12 +144,12 @@ function add_client_events(client) {
|
||||||
console.log(`Successfully connected to ${server_url}.`);
|
console.log(`Successfully connected to ${server_url}.`);
|
||||||
|
|
||||||
server_indicator.innerText = function() {
|
server_indicator.innerText = function() {
|
||||||
if (client.url.startsWith("ws://"))
|
if (server_url.startsWith("ws://"))
|
||||||
return client.url.slice(5, -1);
|
return server_url.slice(5, -1);
|
||||||
else if (client.url.startsWith("wss://"))
|
else if (server_url.startsWith("wss://"))
|
||||||
return client.url.slice(6, -1);
|
return server_url.slice(6, -1);
|
||||||
else
|
else
|
||||||
return client.url;
|
return server_url;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
add_system_message(`Connection successful.\n\n`);
|
add_system_message(`Connection successful.\n\n`);
|
||||||
|
|
Loading…
Reference in a new issue