2015-07-28 15:54:29 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-10-02 14:53:11 +00:00
|
|
|
var socket, soundController;
|
2015-07-28 15:54:29 +00:00
|
|
|
|
2015-10-02 14:53:11 +00:00
|
|
|
var removeAuthWidget = () => $("#authenticating").remove();
|
2015-08-18 09:56:35 +00:00
|
|
|
|
2015-10-02 14:53:11 +00:00
|
|
|
var showAuthenticationNotice = () => $("#auth-required").show();
|
2015-08-18 09:56:35 +00:00
|
|
|
|
2015-10-02 14:53:11 +00:00
|
|
|
var showGatherBanNotice = () => $("#gather-banned").show();
|
2015-08-18 09:56:35 +00:00
|
|
|
|
2015-08-11 00:37:43 +00:00
|
|
|
var initialiseComponents = () => {
|
|
|
|
let socketUrl = window.location.protocol + "//" + window.location.host;
|
2015-07-28 15:54:29 +00:00
|
|
|
socket = io(socketUrl)
|
2015-08-11 00:37:43 +00:00
|
|
|
.on("connect", () => {
|
2015-07-28 15:54:29 +00:00
|
|
|
console.log("Connected");
|
2015-08-18 09:56:35 +00:00
|
|
|
removeAuthWidget();
|
2015-10-02 17:52:04 +00:00
|
|
|
soundController = new SoundController();
|
2015-10-02 14:53:11 +00:00
|
|
|
React.render(<App socket={socket} soundController={soundController}/>,
|
|
|
|
document.getElementById("body_content"));
|
2015-08-27 11:07:45 +00:00
|
|
|
socket.on("reconnect", () => {
|
2015-10-02 14:53:11 +00:00
|
|
|
console.log("Reconnected");
|
2015-08-27 11:07:45 +00:00
|
|
|
socket.emit("message:refresh");
|
|
|
|
socket.emit("gather:refresh");
|
|
|
|
socket.emit("users:refresh");
|
|
|
|
})
|
|
|
|
.on("disconnect", () => {
|
|
|
|
console.log("Disconnected")
|
|
|
|
});
|
2015-08-18 09:56:35 +00:00
|
|
|
})
|
2015-10-02 17:52:04 +00:00
|
|
|
.on("error", error => {
|
2015-08-18 09:56:35 +00:00
|
|
|
console.log(error);
|
|
|
|
if (error === "Authentication Failed") {
|
|
|
|
removeAuthWidget();
|
|
|
|
showAuthenticationNotice();
|
2015-08-27 12:11:38 +00:00
|
|
|
} else if (error === "Gather Banned") {
|
|
|
|
removeAuthWidget();
|
|
|
|
showGatherBanNotice();
|
2015-08-18 09:56:35 +00:00
|
|
|
}
|
2015-08-27 12:13:58 +00:00
|
|
|
});
|
2015-07-29 10:56:01 +00:00
|
|
|
};
|