Website Summary Files Commits Branches @commit @diff @stats
path: root / scripts / app.js
diff options
context:
space:
mode:
Commita28a5052313f0921865d0eb2632fb41c16a60367 (patch)
Author
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-02-28 14:24:18 +0200
Committer
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-02-28 14:24:18 +0200
Filesa39c5c61b1ee6db75872fde46bb364c1e968ecba /scripts/app.js
pusg-front-end-main.tar
pusg-front-end-main.tar.gz
pusg-front-end-main.zip
Parenta9863b87c9ccd4d10fdcd6849436d6a50fae243e (diff)
Introduced Cached messages and Refresh Login HEAD main
* Added Welcome Message * Added Refresh Login when returning from Game * Killed Home Session when starting new game * Moved functionality from Socket Service to respective classes (refactoring)
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;