A hubub of code to test websockets. To remove and refine

This commit is contained in:
GloriousCode
2017-08-31 21:13:42 +10:00
parent af2d8cf157
commit e193258710
11 changed files with 144 additions and 36 deletions

View File

@@ -0,0 +1,34 @@
import { Component, OnInit } from '@angular/core';
import { ChatService } from './../../services/chat.service';
@Component({
selector: 'app-chatbutton',
templateUrl: './chatbutton.component.html',
styleUrls: ['./chatbutton.component.scss']
})
export class ChatbuttonComponent implements OnInit {
constructor(private chatService: ChatService) {
chatService.messages.subscribe(msg => {
console.log("Response from websocket: " + JSON.stringify(msg));
});
}
ngOnInit() {
}
private message = {
author: 'tutorialedge',
message: 'this is a test message',
Event:'auth',
username:'user',
password:'password'
}
sendMsg():void {
console.log('new message from client to websocket: ', this.message);
this.chatService.messages.next(this.message);
this.message.message = '';
}
}