fixed connect() not actually changing server hosts

This commit is contained in:
ari melody 2024-01-19 04:57:53 +00:00
parent c69d0bd891
commit 178313ec2b
Signed by: ari
GPG key ID: CF99829C92678188

View file

@ -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.
* @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
client.close();
@ -144,12 +144,12 @@ function add_client_events(client) {
console.log(`Successfully connected to ${server_url}.`);
server_indicator.innerText = function() {
if (client.url.startsWith("ws://"))
return client.url.slice(5, -1);
else if (client.url.startsWith("wss://"))
return client.url.slice(6, -1);
if (server_url.startsWith("ws://"))
return server_url.slice(5, -1);
else if (server_url.startsWith("wss://"))
return server_url.slice(6, -1);
else
return client.url;
return server_url;
}();
add_system_message(`Connection successful.\n\n`);