mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-17 15:09:59 +00:00
A hubub of code to test websockets. To remove and refine
This commit is contained in:
34
web/src/app/shared/chatbutton/chatbutton.component.ts
Normal file
34
web/src/app/shared/chatbutton/chatbutton.component.ts
Normal 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 = '';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user