diff --git a/src/app/config.ts b/src/app/config.ts
index 3df43bb..2579150 100644
--- a/src/app/config.ts
+++ b/src/app/config.ts
@@ -36,6 +36,9 @@ export const config = {
route: 'messages',
showNextButton: true
},
+ console: {
+ defaultContent: ''
+ },
testmessenger: {
route: 'testmessenger'
}
diff --git a/src/app/console/console-command.ts b/src/app/console/console-command.ts
new file mode 100644
index 0000000..7f05c2b
--- /dev/null
+++ b/src/app/console/console-command.ts
@@ -0,0 +1,7 @@
+// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
+// All Rights Reserved. See LICENSE file for details.
+
+export class ConsoleCommand {
+ command: string;
+ content?: string;
+}
diff --git a/src/app/console/console.component.html b/src/app/console/console.component.html
index cfa8363..cd6f85f 100644
--- a/src/app/console/console.component.html
+++ b/src/app/console/console.component.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/app/console/console.component.ts b/src/app/console/console.component.ts
index 6455c32..e0d18be 100644
--- a/src/app/console/console.component.ts
+++ b/src/app/console/console.component.ts
@@ -2,6 +2,9 @@
// All Rights Reserved. See LICENSE file for details.
import { Component, OnInit } from '@angular/core';
+import { WebSocketService } from '../services/websocket.service';
+import { ConsoleCommand } from './console-command';
+import { config } from '../config';
@Component({
selector: 'app-console',
@@ -9,9 +12,34 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./console.component.scss']
})
export class ConsoleComponent implements OnInit {
+ console_content: string = config.console.defaultContent;
- constructor() {}
+ command_handlers = {
+ 'write': this.writeHandler.bind(this),
+ 'read': this.readHandler.bind(this)
+ };
- ngOnInit() {}
+ constructor(private webSocketService: WebSocketService) {}
+ ngOnInit() {
+ this.webSocketService.connect();
+ this.webSocketService.observeKey('console').subscribe((event) => {
+ this.command_handlers[event.data.command](event.data);
+ });
+ }
+
+ writeHandler(data: ConsoleCommand) {
+ this.console_content = data.content;
+ }
+
+ readHandler(data: ConsoleCommand) {
+ this.sendContent(this.console_content);
+ }
+
+ sendContent(content: string) {
+ this.webSocketService.send('console', {
+ 'command': 'read',
+ 'content': content
+ });
+ }
}