Website Summary Files Commits Branches @commit @diff @stats
path: root / scripts / app.js
diff options
context:
space:
mode:
1 files changed, 15 insertions, 12 deletions
-rw-r--r--scripts/app.js27
diff --git a/scripts/app.js b/scripts/app.js
index 93b999a..a8f8e70 100644
--- a/scripts/app.js
+++ b/scripts/app.js
@@ -1,17 +1,18 @@
var app = app || {};
-const gameEvents = (() => {
- app.eventService.addEventHandler('GameEnd', (result) => {
- if(result) {
- const message = result.result;
- const user = 'PUSG';
+const globalEvents = (() => {
+ app.eventService.addEventHandler('GameStart', (color) => {
+ app.socketService.disconnectHome();
+ app.config.USER.COLOR = color;
+ window.location.hash = '#/play';
+ });
- app.socketService.send('home', 'SendMessage', user, message);
+ app.eventService.addEventHandler('GameEnd', (result) => {
+ if(app.Game.isRunning) {
+ app.Game.reset();
+ app.socketService.disconnectGame();
+ window.location.hash = '#/home';
}
-
- app.Game.reset();
- app.socketService.disconnectGame();
- window.location.hash = '#/home';
});
})();
@@ -26,8 +27,10 @@ const handleRouting = () => {
app.htmlService.clearElement('#app');
app.htmlService.attachElement(compliedTemplate, '#app');
- app.socketService.initHome();
- app.Home.init();
+ app.socketService.initHome().then(() => {
+ app.userService.refreshLogin();
+ app.Home.init();
+ });
});
break;