Loading src/app/app.component.html +2 −2 Original line number Original line Diff line number Diff line <div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg); background-repeat: repeat;" > <div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg); background-repeat: repeat;" > <app-header> <app-header socket="{{socket}}"> </app-header> </app-header> <div fxFlex> <div fxFlex> <router-outlet></router-outlet> <router-outlet (activate)="socket"></router-outlet> </div> </div> <app-footer> <app-footer> <mat-toolbar color="primary"> <mat-toolbar color="primary"> Loading src/app/app.component.ts +11 −2 Original line number Original line Diff line number Diff line import { Component } from '@angular/core'; import {Component, OnInit, Output} from '@angular/core'; import {io} from 'socket.io-client'; import {environment} from '../environments/environment'; @Component({ @Component({ selector: 'app-root', selector: 'app-root', templateUrl: './app.component.html', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss'] }) }) export class AppComponent { export class AppComponent implements OnInit { @Output() socket: any; title = 'Tabu'; title = 'Tabu'; ngOnInit(): void { //this.socket = io(environment.tabuServerURL); } } } src/app/dao/TabuMiddlewareService.ts +0 −8 Original line number Original line Diff line number Diff line Loading @@ -35,42 +35,34 @@ export class TabuMiddlewareService { } } getGamestatus(req: any): Promise<any> { getGamestatus(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); } } getS2C(req: any): Promise<any> { getS2C(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req); } } addPoint(req: any): Promise<any> { addPoint(req: any): Promise<any> { console.log('TestAddPoint: ', req); return this.request('POST', `${environment.tabuMiddlewareURL}addPoint`, req); return this.request('POST', `${environment.tabuMiddlewareURL}addPoint`, req); } } removePoint(req: any): Promise<any> { removePoint(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req); return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req); } } newGame(req: any): Promise<any> { newGame(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}newGame`, req); return this.request('POST', `${environment.tabuMiddlewareURL}newGame`, req); } } newRound(req: any): Promise<any> { newRound(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}newRound`, req); return this.request('POST', `${environment.tabuMiddlewareURL}newRound`, req); } } endRound(req: any): Promise<any> { endRound(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}endRound`, req); return this.request('POST', `${environment.tabuMiddlewareURL}endRound`, req); } } getCard(req: any): Promise<any> { getCard(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getCard`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getCard`, req); } } } } src/app/error/error.component.ts +1 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ export class ErrorComponent implements OnInit { ngOnInit(): void { ngOnInit(): void { this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL); this.socket.disconnect(); this.listen(); this.listen(); } } Loading src/app/game/game.component.ts +13 −10 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,6 @@ import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {Environment} from '@angular/compiler-cli/src/ngtsc/typecheck/src/environment'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; @Component({ @Component({ Loading @@ -16,6 +15,7 @@ import {environment} from '../../environments/environment'; export class GameComponent implements OnInit { export class GameComponent implements OnInit { socket: any; socket: any; init = true; sessionName = ''; sessionName = ''; isWatchdog = false; isWatchdog = false; isExplainer = false; isExplainer = false; Loading Loading @@ -65,20 +65,29 @@ export class GameComponent implements OnInit { this.fillGamestatus(); this.fillGamestatus(); this.team = String(params.get('team')); this.team = String(params.get('team')); this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL); this.listen(); this.listen() }); }); this.startTimer(); this.startTimer(); } } listen(): any { listen(): any { this.socket.on(this.sessionName + ':newCard', (data: any) => { this.socket.on(this.sessionName + ':newCard', (data: any) => { console.log('CardID:' , data); this.service.getCard({cardID: data}).then(value => { this.service.getCard({cardID: data}).then(value => { console.log('NewCard: ', value); this.fillNewCard(value); this.fillNewCard(value); this.fillGamestatus(); this.fillGamestatus(); }); }); }); }); this.socket.on(this.sessionName + ':endRound', (data: any) => { console.log('GAME: ', data); if (JSON.parse(data)) { if (this.init) { this.init = false; } console.log('GAME END: ', data); this.socket.disconnect(); this.router.navigate([this.sessionName + '/' + this.team]); } }); } } onTimesUp(): void{ onTimesUp(): void{ Loading Loading @@ -109,7 +118,6 @@ export class GameComponent implements OnInit { this.gameStatus.red = JSON.parse(value.red); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.blue = JSON.parse(value.blue); }); }); console.log(this.gameStatus); } } wrongAnswer(): void{ wrongAnswer(): void{ Loading @@ -121,18 +129,14 @@ export class GameComponent implements OnInit { this.gameStatus.red = JSON.parse(value.red); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.blue = JSON.parse(value.blue); }); }); console.log(this.gameStatus); } } newCard(): void{ newCard(): void{ this.service.getS2C({spielname: this.sessionName}).then(value => { this.service.getS2C({spielname: this.sessionName}).then(value => { console.log('Test1:', value); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { console.log('Test2:', value); this.fillNewCard(value); this.fillNewCard(value); } } console.log(this.cardInfo); }).catch(reason => console.log(reason)); }).catch(reason => console.log(reason)); } } Loading @@ -157,7 +161,6 @@ export class GameComponent implements OnInit { this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); } } console.log(this.gameStatus); }); }); } } } } Loading
src/app/app.component.html +2 −2 Original line number Original line Diff line number Diff line <div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg); background-repeat: repeat;" > <div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg); background-repeat: repeat;" > <app-header> <app-header socket="{{socket}}"> </app-header> </app-header> <div fxFlex> <div fxFlex> <router-outlet></router-outlet> <router-outlet (activate)="socket"></router-outlet> </div> </div> <app-footer> <app-footer> <mat-toolbar color="primary"> <mat-toolbar color="primary"> Loading
src/app/app.component.ts +11 −2 Original line number Original line Diff line number Diff line import { Component } from '@angular/core'; import {Component, OnInit, Output} from '@angular/core'; import {io} from 'socket.io-client'; import {environment} from '../environments/environment'; @Component({ @Component({ selector: 'app-root', selector: 'app-root', templateUrl: './app.component.html', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss'] }) }) export class AppComponent { export class AppComponent implements OnInit { @Output() socket: any; title = 'Tabu'; title = 'Tabu'; ngOnInit(): void { //this.socket = io(environment.tabuServerURL); } } }
src/app/dao/TabuMiddlewareService.ts +0 −8 Original line number Original line Diff line number Diff line Loading @@ -35,42 +35,34 @@ export class TabuMiddlewareService { } } getGamestatus(req: any): Promise<any> { getGamestatus(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); } } getS2C(req: any): Promise<any> { getS2C(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req); } } addPoint(req: any): Promise<any> { addPoint(req: any): Promise<any> { console.log('TestAddPoint: ', req); return this.request('POST', `${environment.tabuMiddlewareURL}addPoint`, req); return this.request('POST', `${environment.tabuMiddlewareURL}addPoint`, req); } } removePoint(req: any): Promise<any> { removePoint(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req); return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req); } } newGame(req: any): Promise<any> { newGame(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}newGame`, req); return this.request('POST', `${environment.tabuMiddlewareURL}newGame`, req); } } newRound(req: any): Promise<any> { newRound(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}newRound`, req); return this.request('POST', `${environment.tabuMiddlewareURL}newRound`, req); } } endRound(req: any): Promise<any> { endRound(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}endRound`, req); return this.request('POST', `${environment.tabuMiddlewareURL}endRound`, req); } } getCard(req: any): Promise<any> { getCard(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getCard`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getCard`, req); } } } }
src/app/error/error.component.ts +1 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ export class ErrorComponent implements OnInit { ngOnInit(): void { ngOnInit(): void { this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL); this.socket.disconnect(); this.listen(); this.listen(); } } Loading
src/app/game/game.component.ts +13 −10 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,6 @@ import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {Environment} from '@angular/compiler-cli/src/ngtsc/typecheck/src/environment'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; @Component({ @Component({ Loading @@ -16,6 +15,7 @@ import {environment} from '../../environments/environment'; export class GameComponent implements OnInit { export class GameComponent implements OnInit { socket: any; socket: any; init = true; sessionName = ''; sessionName = ''; isWatchdog = false; isWatchdog = false; isExplainer = false; isExplainer = false; Loading Loading @@ -65,20 +65,29 @@ export class GameComponent implements OnInit { this.fillGamestatus(); this.fillGamestatus(); this.team = String(params.get('team')); this.team = String(params.get('team')); this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL); this.listen(); this.listen() }); }); this.startTimer(); this.startTimer(); } } listen(): any { listen(): any { this.socket.on(this.sessionName + ':newCard', (data: any) => { this.socket.on(this.sessionName + ':newCard', (data: any) => { console.log('CardID:' , data); this.service.getCard({cardID: data}).then(value => { this.service.getCard({cardID: data}).then(value => { console.log('NewCard: ', value); this.fillNewCard(value); this.fillNewCard(value); this.fillGamestatus(); this.fillGamestatus(); }); }); }); }); this.socket.on(this.sessionName + ':endRound', (data: any) => { console.log('GAME: ', data); if (JSON.parse(data)) { if (this.init) { this.init = false; } console.log('GAME END: ', data); this.socket.disconnect(); this.router.navigate([this.sessionName + '/' + this.team]); } }); } } onTimesUp(): void{ onTimesUp(): void{ Loading Loading @@ -109,7 +118,6 @@ export class GameComponent implements OnInit { this.gameStatus.red = JSON.parse(value.red); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.blue = JSON.parse(value.blue); }); }); console.log(this.gameStatus); } } wrongAnswer(): void{ wrongAnswer(): void{ Loading @@ -121,18 +129,14 @@ export class GameComponent implements OnInit { this.gameStatus.red = JSON.parse(value.red); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.blue = JSON.parse(value.blue); }); }); console.log(this.gameStatus); } } newCard(): void{ newCard(): void{ this.service.getS2C({spielname: this.sessionName}).then(value => { this.service.getS2C({spielname: this.sessionName}).then(value => { console.log('Test1:', value); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { console.log('Test2:', value); this.fillNewCard(value); this.fillNewCard(value); } } console.log(this.cardInfo); }).catch(reason => console.log(reason)); }).catch(reason => console.log(reason)); } } Loading @@ -157,7 +161,6 @@ export class GameComponent implements OnInit { this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); } } console.log(this.gameStatus); }); }); } } } }