28 lines
745 B
JavaScript
28 lines
745 B
JavaScript
"use strict";
|
|
|
|
// Global object for debugging purposes
|
|
let client;
|
|
|
|
// Execute this on start (wrapped in an anonymous function)
|
|
(function() {
|
|
const wsUri = AppSettings.serverWsUri;
|
|
client = new Client(wsUri);
|
|
|
|
// Test events
|
|
client.on("initialized", () => {
|
|
console.log("UI: Connection initialized!");
|
|
|
|
// Send a test message
|
|
client.sendChatMessage("Meow meow! :3");
|
|
});
|
|
client.on("disconnected", () => {
|
|
console.log("UI: Connection closed!");
|
|
});
|
|
client.on("connectionError", () => {
|
|
console.log("UI: Connection error! :()");
|
|
});
|
|
client.on("receivedMessage", (msg) => {
|
|
console.log("UI: Message from '" + msg.from + "', text: '" + msg.text + "'");
|
|
});
|
|
})();
|