24 lines
690 B
TypeScript
24 lines
690 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { WebSocketService } from '../services/websocket.service';
|
|
|
|
@Component({
|
|
selector: 'app-testmessager',
|
|
templateUrl: './testmessenger.component.html',
|
|
styleUrls: ['./testmessenger.component.scss']
|
|
})
|
|
export class TestmessengerComponent implements OnInit {
|
|
messageStr = `{\n "key": "",\n "data": {},\n "trigger": ""\n}`;
|
|
|
|
constructor(private webSocketService: WebSocketService) {}
|
|
|
|
ngOnInit() {
|
|
this.webSocketService.connect();
|
|
this.webSocketService.observeKey('').subscribe();
|
|
}
|
|
|
|
sendTestMessage() {
|
|
const jsonObject = JSON.parse(this.messageStr);
|
|
this.webSocketService.sendJSON(jsonObject);
|
|
}
|
|
}
|