mirror of https://github.com/opencardev/aasdk
Handle ping request/response
parent
839fd0f7af
commit
64bc6bf137
|
@ -47,6 +47,7 @@ public:
|
||||||
void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) override;
|
void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) override;
|
||||||
void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) override;
|
void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) override;
|
||||||
void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& respons, SendPromise::Pointer promisee) override;
|
void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& respons, SendPromise::Pointer promisee) override;
|
||||||
|
void sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<ControlServiceChannel>::shared_from_this;
|
using std::enable_shared_from_this<ControlServiceChannel>::shared_from_this;
|
||||||
|
@ -58,6 +59,7 @@ private:
|
||||||
void handleShutdownRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
void handleShutdownRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
||||||
void handleShutdownResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
void handleShutdownResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
||||||
void handleNavigationFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
void handleNavigationFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handlePingResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <aasdk_proto/AudioFocusResponseMessage.pb.h>
|
#include <aasdk_proto/AudioFocusResponseMessage.pb.h>
|
||||||
#include <aasdk_proto/NavigationFocusResponseMessage.pb.h>
|
#include <aasdk_proto/NavigationFocusResponseMessage.pb.h>
|
||||||
#include <aasdk_proto/StatusEnum.pb.h>
|
#include <aasdk_proto/StatusEnum.pb.h>
|
||||||
|
#include <aasdk_proto/PingRequestMessage.pb.h>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <f1x/aasdk/Common/Data.hpp>
|
||||||
#include <f1x/aasdk/Channel/Promise.hpp>
|
#include <f1x/aasdk/Channel/Promise.hpp>
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
||||||
|
@ -56,6 +57,7 @@ public:
|
||||||
virtual void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) = 0;
|
virtual void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) = 0;
|
||||||
virtual void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) = 0;
|
virtual void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) = 0;
|
||||||
virtual void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& response, SendPromise::Pointer promise) = 0;
|
virtual void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& response, SendPromise::Pointer promise) = 0;
|
||||||
|
virtual void sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <aasdk_proto/ServiceDiscoveryRequestMessage.pb.h>
|
#include <aasdk_proto/ServiceDiscoveryRequestMessage.pb.h>
|
||||||
#include <aasdk_proto/AudioFocusRequestMessage.pb.h>
|
#include <aasdk_proto/AudioFocusRequestMessage.pb.h>
|
||||||
#include <aasdk_proto/NavigationFocusRequestMessage.pb.h>
|
#include <aasdk_proto/NavigationFocusRequestMessage.pb.h>
|
||||||
|
#include <aasdk_proto/PingResponseMessage.pb.h>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -51,6 +52,7 @@ public:
|
||||||
virtual void onShutdownRequest(const proto::messages::ShutdownRequest& request) = 0;
|
virtual void onShutdownRequest(const proto::messages::ShutdownRequest& request) = 0;
|
||||||
virtual void onShutdownResponse(const proto::messages::ShutdownResponse& response) = 0;
|
virtual void onShutdownResponse(const proto::messages::ShutdownResponse& response) = 0;
|
||||||
virtual void onNavigationFocusRequest(const proto::messages::NavigationFocusRequest& request) = 0;
|
virtual void onNavigationFocusRequest(const proto::messages::NavigationFocusRequest& request) = 0;
|
||||||
|
virtual void onPingResponse(const proto::messages::PingResponse& response) = 0;
|
||||||
virtual void onChannelError(const error::Error& e) = 0;
|
virtual void onChannelError(const error::Error& e) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,15 @@ void ControlServiceChannel::sendNavigationFocusResponse(const proto::messages::N
|
||||||
this->send(std::move(message), std::move(promise));
|
this->send(std::move(message), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlServiceChannel::sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise)
|
||||||
|
{
|
||||||
|
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
|
||||||
|
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::PING_REQUEST).getData());
|
||||||
|
message->insertPayload(request);
|
||||||
|
|
||||||
|
this->send(std::move(message), std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void ControlServiceChannel::receive(IControlServiceChannelEventHandler::Pointer eventHandler)
|
void ControlServiceChannel::receive(IControlServiceChannelEventHandler::Pointer eventHandler)
|
||||||
{
|
{
|
||||||
auto receivePromise = messenger::ReceivePromise::defer(strand_);
|
auto receivePromise = messenger::ReceivePromise::defer(strand_);
|
||||||
|
@ -152,6 +161,9 @@ void ControlServiceChannel::messageHandler(messenger::Message::Pointer message,
|
||||||
case proto::ids::ControlMessage::NAVIGATION_FOCUS_REQUEST:
|
case proto::ids::ControlMessage::NAVIGATION_FOCUS_REQUEST:
|
||||||
this->handleNavigationFocusRequest(payload, std::move(eventHandler));
|
this->handleNavigationFocusRequest(payload, std::move(eventHandler));
|
||||||
break;
|
break;
|
||||||
|
case proto::ids::ControlMessage::PING_RESPONSE:
|
||||||
|
this->handlePingResponse(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
AASDK_LOG(error) << "[ControlServiceChannel] message not handled: " << messageId.getId();
|
AASDK_LOG(error) << "[ControlServiceChannel] message not handled: " << messageId.getId();
|
||||||
this->receive(std::move(eventHandler));
|
this->receive(std::move(eventHandler));
|
||||||
|
@ -236,6 +248,19 @@ void ControlServiceChannel::handleNavigationFocusRequest(const common::DataConst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlServiceChannel::handlePingResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::PingResponse response;
|
||||||
|
if(response.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onPingResponse(response);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue