Client: Implement event system (#4)

This commit is contained in:
Lexi / Zoe 2019-01-20 21:12:41 +01:00
parent 36ba716ad8
commit ceca822f97
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
4 changed files with 81 additions and 7 deletions

View file

@ -7,4 +7,21 @@ let client;
(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 + "'");
});
})();