Client: add global AppSettings object

This commit is contained in:
Lexi / Zoe 2019-01-20 02:06:30 +01:00
parent 3993ae9c44
commit 98c89f0702
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
3 changed files with 11 additions and 4 deletions

View File

@ -11,6 +11,7 @@
<h1>InstantChat</h1> <h1>InstantChat</h1>
<script src="js/settings.js"></script>
<script src="js/client.js"></script> <script src="js/client.js"></script>
</body> </body>

View File

@ -1,6 +1,4 @@
// Constants and variables "use strict";
// const wsUri = "ws://localhost:32715";
const wsUri = "wss://chat.glitch-in.space:443/ws/";
class Client { class Client {
constructor(wsUri) { constructor(wsUri) {
@ -17,7 +15,7 @@ class Client {
// WebSocket event handlers // WebSocket event handlers
onOpen(evt) { onOpen(evt) {
console.log("Connected to " + wsUri); console.log("Connected to " + this.wsUri);
// Send init command containing chat ID and nickname // Send init command containing chat ID and nickname
this.sendInit(); this.sendInit();
@ -83,5 +81,6 @@ class Client {
// Run script after page is loaded // Run script after page is loaded
$(function() { $(function() {
const wsUri = AppSettings.serverWsUri;
let client = new Client(wsUri); let client = new Client(wsUri);
}); });

View File

@ -0,0 +1,7 @@
"use strict";
// Global settings object
const AppSettings = {
// serverWsUri: "ws://localhost:32715",
serverWsUri: "wss://chat.glitch-in.space:443/ws/",
};