diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts index 91157af..017e2b2 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts @@ -1,15 +1,27 @@ import { Component, OnInit } from '@angular/core'; -import {AbilityViewModel} from "../../../types/viewmodels/ability-viewmodels/AbilityViewModel"; +import { AbilityViewModel } from "../../../types/viewmodels/ability-viewmodels/AbilityViewModel"; +import { PlayerSignalRService } from "../../shared/signalR-service/player-signalR.service"; +import { first } from "rxjs/operators"; +import { Store } from '@ngrx/store'; +import { AppState } from 'src/app/store/models/app-state.model'; @Component({ selector: 'app-player-dashboard', templateUrl: './player-dashboard.component.html', styleUrls: ['./player-dashboard.component.css'], }) -export class PlayerDashboardComponent { +export class PlayerDashboardComponent implements OnInit { isExpanded = false; selected = false; + constructor(private signalRService: PlayerSignalRService, private store: Store) {} + + ngOnInit() { + this.store.select(s => s.playerStore.characterId).pipe(first()).subscribe((id) => { + this.signalRService.Login(id); + }); + } + ability: AbilityViewModel = { id: 1, name: 'Strength', @@ -26,10 +38,6 @@ export class PlayerDashboardComponent { ] } - collapse() { - this.isExpanded = false; - } - toggle() { this.isExpanded = !this.isExpanded; } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/sign-in/sign-in.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/sign-in/sign-in.component.ts index 1bf5263..424e36a 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/sign-in/sign-in.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/sign-in/sign-in.component.ts @@ -3,10 +3,9 @@ import { FormGroup, Validators, FormBuilder } from '@angular/forms'; import { Router } from '@angular/router'; import {UserService} from '../../../services/user.service'; import {ErrorResponse} from '../../../types/ErrorResponse'; -import {Observable, Subscription} from 'rxjs'; +import {Subscription} from 'rxjs'; import {HttpErrorResponse} from '@angular/common/http'; -import {AppStoreModel} from '../../store/models/app-store.model'; -import {select, Store} from '@ngrx/store'; +import {Store} from '@ngrx/store'; import {AddUserId} from '../../store/actions/app.actions'; import {AppState} from 'src/app/store/models/app-state.model'; import {first} from "rxjs/operators"; @@ -18,9 +17,6 @@ import {first} from "rxjs/operators"; }) export class SignInComponent implements OnDestroy, OnInit { allSubscriptions = new Subscription(); - - role$: Observable; - isExpanded = false; apiError = false; apiErrorMessage = ''; @@ -39,7 +35,6 @@ export class SignInComponent implements OnDestroy, OnInit { }); ngOnInit() { - this.role$ = this.store.select(s => s.appStore); } onLoginButtonClick() { @@ -77,10 +72,6 @@ export class SignInComponent implements OnDestroy, OnInit { this.router.navigate(['']); } - collapse() { - this.isExpanded = false; - } - toggle() { this.isExpanded = !this.isExpanded; } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/shared/signalR-service/player-signalR.service.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/shared/signalR-service/player-signalR.service.ts index 31db81f..cbe292f 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/shared/signalR-service/player-signalR.service.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/shared/signalR-service/player-signalR.service.ts @@ -8,15 +8,14 @@ export class PlayerSignalRService { constructor(@Inject('BASE_URL') baseUrl: string) { this.signalR = new SignalRService(baseUrl); this.registerOnServerEvents(); - this.signalR.startConnection(); } - public Login() { + public Login(characterId: number) { this.signalR.startConnection(); this.signalR.connectionEstablished$.subscribe(() => { if (this.signalR.connectionEstablished$.getValue() === true) { - this.signalR.hubConnection.send('GameMasterLogin'); + this.signalR.hubConnection.send('PlayerCharacterLogin', characterId); } }); }