From 338d333b0431b46860cde991766de65e2dce38ae Mon Sep 17 00:00:00 2001 From: Matthew Territo Date: Mon, 6 Aug 2018 16:37:57 -0600 Subject: [PATCH] Send disconnect and connect packets --- modules/server/include/topics/flightcontrollertopic.h | 1 + modules/server/src/topics/flightcontrollertopic.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/server/include/topics/flightcontrollertopic.h b/modules/server/include/topics/flightcontrollertopic.h index 29f276bacc..23aa8b4737 100644 --- a/modules/server/include/topics/flightcontrollertopic.h +++ b/modules/server/include/topics/flightcontrollertopic.h @@ -47,6 +47,7 @@ public: private: bool _isDone; + nlohmann::json _payload; nlohmann::json _focusNodes; openspace::interaction::WebsocketInputStates _inputStates; diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index d7b5172aeb..f4074e5e48 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -59,6 +59,9 @@ namespace { constexpr const char* _loggerCat = "FlightControllerTopic"; constexpr const char* TypeKey = "type"; constexpr const char* ValuesKey = "values"; + constexpr const char* SuccessKey = "success"; + + constexpr const char* FocusNodesKey = "focusNodes"; constexpr const char* FlightControllerType = "flightcontroller"; @@ -149,7 +152,10 @@ void FlightControllerTopic::handleJson(const nlohmann::json& json) { void FlightControllerTopic::connect() { _isDone = false; std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0); + _payload[TypeKey] = Connect; setFocusNodes(); + _payload[Connect][FocusNodesKey] = _focusNodes; + _connection->sendJson(wrappedPayload(_payload)); } void FlightControllerTopic::setFocusNodes() { @@ -171,12 +177,15 @@ void FlightControllerTopic::setFocusNodes() { _focusNodes[n->guiName()] = n->identifier(); } } - _connection->sendJson(wrappedPayload(_focusNodes)); } void FlightControllerTopic::disconnect() { OsEng.navigationHandler().removeWebsocketInputState(_topicId); _isDone = true; + nlohmann::json j; + j[TypeKey] = Disconnect; + j[Disconnect][SuccessKey] = true; + _connection->sendJson(wrappedPayload(j)); } void FlightControllerTopic::processInputState(const nlohmann::json& json) {