mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-04-08 23:19:48 +00:00
27 lines
803 B
TypeScript
27 lines
803 B
TypeScript
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
// All Rights Reserved. See LICENSE file for details.
|
|
|
|
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);
|
|
}
|
|
}
|