-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock_breezy.jl
53 lines (48 loc) · 1.25 KB
/
mock_breezy.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using DotaBot
using HTTP
using ArgParse
using Sockets
using JSON
s = ArgParseSettings()
@add_arg_table! s begin
"--breezyIP"
help = "breezy server IP adress"
default = "127.0.0.1"
"--breezyPort"
help = "breezy server port number"
default = "8085"
"--agentIP"
help = "agent server IP adress"
default = "127.0.0.1"
"--agentPort"
help = "agent server port number"
default = "8086"
end
args = parse_args(ARGS, s)
@async HTTP.serve(parse(IPAddr, args["breezyIP"]), parse(Int, args["breezyPort"])) do request::HTTP.Request
@show request
@show request.method
@show HTTP.header(request, "Content-Type")
@show HTTP.payload(request)
try
return HTTP.Response(200, "okay")
catch e
println(e)
return HTTP.Response(404, "Error: $e")
end
end
sleep(1)
global i = 1
while true
if mod(i, 10) == 0
HTTP.post(string(DotaBot.agent_ip(args), "/update"), ["Content-Type" => "application/json"],
JSON.json(Dict("status"=>"DONE")))
else
features = rand(310)
println(features[1])
HTTP.post(string(DotaBot.agent_ip(args), "/"),
["Content-Type" => "application/json"], JSON.json(features))
end
sleep(0.1)
global i += 1
end