Commit 3a5e08e4 authored by Dennis Willers's avatar Dennis Willers 🏀

Add Socket.io and test it on error page

parent 5477ea1c
This diff is collapsed.
......@@ -7,6 +7,7 @@
<br>
<mat-progress-spinner color="primary" mode="determinate" value="value">
</mat-progress-spinner>
<button (click)="move('left')">Test me</button>
</div>
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import {io} from 'socket.io-client';
@Component({
selector: 'app-error',
......@@ -8,12 +9,26 @@ import {Router} from '@angular/router';
})
export class ErrorComponent implements OnInit {
private socket: any;
constructor(private router: Router) {}
ngOnInit(): void {
this.socket = io('http://localhost:3000');
this.listen();
}
listen(): any {
this.socket.on('position', (data: any) => {
console.log('Listener:' , data);
});
}
toStartpage(): void {
this.router.navigate(['']);
}
move(direction: string): any {
console.log('left: ', direction);
this.socket.emit('move', direction);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment