Add mode switching.

This commit is contained in:
2020-05-23 13:55:16 +02:00
parent 2907cf6574
commit 87bfce1a46
6 changed files with 75 additions and 39 deletions

View File

@@ -1,11 +1,11 @@
import net, json, strutils
import commands
import common
type
ServerArgs* = object of RootObj
verbose: bool
var
var
chan*: Channel[CommandMessage]
verbose: bool
@@ -31,7 +31,7 @@ proc runServer*[ServerArgs](arg: ServerArgs) {.thread, nimcall.} =
server.listen()
log "Control server is listening"
while true:
while true:
# Process client requests
var client = net.newSocket()
server.accept(client)
@@ -41,7 +41,7 @@ proc runServer*[ServerArgs](arg: ServerArgs) {.thread, nimcall.} =
if line == "":
log "No data from client"
continue
var jsonData = parseJson(line)
let msg = jsonData.to(CommandMessage)
case msg.command