@@ -34,7 +34,12 @@ class SetupClient
34
34
workerId = @ getWorkerId ()
35
35
await @ sendTestWorkEvent workerId, serverIp, serverPort
36
36
37
- # Deploy a ContractPen contract to an Accord Project folder structure
37
+ program .usage (' testwork2 <server ip address> <server port>' ).command (' testwork2 <server ip address> <server port>' ).action (serverIp, serverPort, cmd) =>
38
+ console .log ' send test work event'
39
+ workerId = @ getWorkerId ()
40
+ await @ sendTestWorkEvent2 workerId, serverIp, serverPort
41
+
42
+ # ?
38
43
program .usage (' template <input json file> <directory of project>' ).command (' template <input json file> <directory of project>' ).action (inputJsonFile, directory, cmd) =>
39
44
console .log ' template ' + inputJsonFile + ' directory ' + directory
40
45
await @ templateProcess inputJsonFile, directory
@@ -125,7 +130,25 @@ class SetupClient
125
130
return
126
131
127
132
128
- # request.post "http://#{serverId}:#{port}/api/submitTask", { json: true }, (err, res, body) ->
133
+ sendTestWorkEvent2 : (workerId , serverId , port ) ->
134
+ workData =
135
+ fromWorkerId : workerId
136
+ targetWorkerId : null
137
+ sendResultToWorkerId : null
138
+ command : ' template'
139
+ params : [' test_template.json' , ' C:\\ home\\ projects\\ accord\\ cicero-template-library\\ src\\ helloworld' ]
140
+
141
+ request .post {
142
+ url : " http://#{ serverId} :#{ port} /api/submitTask"
143
+ body : workData
144
+ json : true
145
+ }, (error , response , body ) ->
146
+ if error
147
+ return console .error (' failed to send work test event:' , error)
148
+ console .log ' Upload successful! Server responded with:' , body
149
+ return
150
+
151
+ # request.post "http://#{serverId}:#{port}/api/submitTask", { json: true }, (err, res, body) ->
129
152
# if err
130
153
# return console.log(err)
131
154
# console.log body
@@ -139,7 +162,7 @@ class SetupClient
139
162
if (command == ' execute' )
140
163
result = @ execute params[0 ], params[1 ], params[2 ], params[3 ]
141
164
if (command == ' template' )
142
- result = @ template params[0 ], params[1 ]
165
+ result = await @ templateProcess params[0 ], params[1 ]
143
166
if (command == ' export' )
144
167
result = @ export params[0 ], params[1 ]
145
168
if (command == ' exportmulti' )
@@ -154,16 +177,27 @@ class SetupClient
154
177
job = JSON .parse (job)
155
178
console .log ' job command ' + job .command
156
179
result = @ commandSwitcher job .command , job .params
157
- console .log ' execute job called from the server'
158
- # If the directory exists then we say success
159
- workerId = @ getWorkerId ()
160
- socket .send ' finishedJob' ,
161
- workerId : @ getWorkerId ()
162
- job : job
163
- result :
164
- job : job
180
+ result .then (r) =>
181
+ console .log ' execute job called from the server and finished'
182
+ console .log r
183
+
184
+ # The result depends on the command
185
+ # deploy: If the folder exists
186
+ # execute: The result
187
+ # template: The result is the text of the template result
188
+ # export: The second parameter is the json file to return
189
+ # exportMulti: The second parameter is the json file to return
190
+
191
+ # If the directory exists then we say success
192
+ workerId = @ getWorkerId ()
193
+ socket .send ' finishedJob' ,
165
194
workerId : @ getWorkerId ()
166
- workerId : workerId
195
+ job : job
196
+ result :
197
+ job : job
198
+ workerId : @ getWorkerId ()
199
+ workerId : workerId
200
+ returnResultFromFunctionExecution : r
167
201
return
168
202
169
203
# When the server is connected we send back to the server that we are ready to accept commands
0 commit comments