From 373f6c397afa78839d475637bd129c33190997e0 Mon Sep 17 00:00:00 2001 From: Mathew Date: Thu, 20 Jun 2019 12:45:08 +0200 Subject: [PATCH] Socket commands --- public/packages/Socket.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/public/packages/Socket.js b/public/packages/Socket.js index 4d2eb9a..e7e3b93 100644 --- a/public/packages/Socket.js +++ b/public/packages/Socket.js @@ -14,6 +14,32 @@ class Request { } } +export var commands = { + 'socket': com => { + var actions = { + 'connect': ()=> { + if (com.con.Socket.socket.disconnected) { + com.con.Socket.socket.connect() + com.log(`Connecting to ${com.con.Socket.hostname}`, 'info') + } else { + com.log(`Socket already connected`, 'error') + } + + }, + 'disconnect': () => { + if (com.con.Socket.socket.connected){ + com.con.Socket.socket.disconnect() + com.log(`Disconnecting from ${com.con.Socket.hostname}`, 'warning') + } else { + com.log(`Socket not connected`, 'error') + } + + } + } + actions[com.arg[0]]() + } +} + export default class Socket { constructor(con) {