Merge pull request 'SES-140 connected Player with SignalR' (#61) from SES-140 into dev
Reviewed-on: #61
This commit is contained in:
commit
b13a34044b
@ -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<AppState>) {}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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<AppStoreModel>;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user