|
@ -80,11 +80,14 @@ websockets::TestProtocol<Empty> uberclient_protocol{ |
|
|
}, |
|
|
}, |
|
|
// write (will always come after receive)
|
|
|
// write (will always come after receive)
|
|
|
[](Empty& user, basic_websocket_info) -> std::string{ |
|
|
[](Empty& user, basic_websocket_info) -> std::string{ |
|
|
static int i = 0; |
|
|
if(app->offline_sim.lines_to_add.empty()) return ""; |
|
|
return std::to_string(i++); |
|
|
auto it = app->offline_sim.lines_to_add.begin(); |
|
|
|
|
|
auto str = write_json(to_json(*it)); |
|
|
|
|
|
app->offline_sim.lines_to_add.erase(it); |
|
|
|
|
|
return str; |
|
|
}, |
|
|
}, |
|
|
// receive
|
|
|
// receive
|
|
|
[](Empty& user, std::string in, basic_websocket_info){ |
|
|
[](Empty& user, std::string in, basic_websocket_info binfo){ |
|
|
auto object = parse_json(in).getObject(); |
|
|
auto object = parse_json(in).getObject(); |
|
|
if(object.count("lines")){ |
|
|
if(object.count("lines")){ |
|
|
app->offline_sim.lines.clear(); |
|
|
app->offline_sim.lines.clear(); |
|
@ -92,6 +95,7 @@ websockets::TestProtocol<Empty> uberclient_protocol{ |
|
|
for(auto&& js : lines.getArray()){ |
|
|
for(auto&& js : lines.getArray()){ |
|
|
app->offline_sim.lines.push_back(from_json<cheap_line_type>(js)); |
|
|
app->offline_sim.lines.push_back(from_json<cheap_line_type>(js)); |
|
|
} |
|
|
} |
|
|
|
|
|
app->lines_changed(); |
|
|
} |
|
|
} |
|
|
if(object.count("balls")){ |
|
|
if(object.count("balls")){ |
|
|
app->offline_sim.balls.clear(); |
|
|
app->offline_sim.balls.clear(); |
|
@ -100,6 +104,10 @@ websockets::TestProtocol<Empty> uberclient_protocol{ |
|
|
app->offline_sim.balls.push_back(from_json<cheap_ball_type>(js)); |
|
|
app->offline_sim.balls.push_back(from_json<cheap_ball_type>(js)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!app->offline_sim.lines_to_add.empty()){ |
|
|
|
|
|
request_write(binfo); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|