|
@ -30,10 +30,11 @@ websockets::TestProtocol<User> default_protocol{ |
|
|
// write (will always come after receive)
|
|
|
// write (will always come after receive)
|
|
|
[](User& user, basic_websocket_info) -> std::string{ |
|
|
[](User& user, basic_websocket_info) -> std::string{ |
|
|
js::Object ret; |
|
|
js::Object ret; |
|
|
ret["balls"] = vector_to_json(app->sim.balls, [](ball_type const & b){return cheap_ball_type(b);}); |
|
|
|
|
|
if(user.update_lines){ |
|
|
if(user.update_lines){ |
|
|
ret["lines"] = vector_to_json(app->lines, [](AbstractLine const & l){return cheap_line_type(l);}); |
|
|
ret["lines"] = vector_to_json(app->lines, [](AbstractLine const & l){return cheap_line_type(l);}); |
|
|
user.update_lines = false; |
|
|
user.update_lines = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
ret["balls"] = vector_to_json(app->sim.balls, [](ball_type const & b){return cheap_ball_type(b);}); |
|
|
} |
|
|
} |
|
|
return write_json(ret); |
|
|
return write_json(ret); |
|
|
}, |
|
|
}, |
|
|