Client: add global AppSettings object
This commit is contained in:
parent
3993ae9c44
commit
98c89f0702
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Global settings object
|
||||||
|
const AppSettings = {
|
||||||
|
// serverWsUri: "ws://localhost:32715",
|
||||||
|
serverWsUri: "wss://chat.glitch-in.space:443/ws/",
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue