#include "cast/streaming/public/session_messenger.h"
#include <chrono>
#include <string>
#include "cast/common/public/message_port.h"
#include "cast/streaming/message_fields.h"
#include "platform/base/trivial_clock_traits.h"
#include "util/json/json_helpers.h"
#include "util/json/json_serialization.h"
#include "util/osp_logging.h"
#include "util/string_util.h"
namespace openscreen::cast {
namespace {
constexpr std::chrono::milliseconds kReplyTimeout{ … };
constexpr char kAnyDestination[] = …;
void ReplyIfTimedOut(
int sequence_number,
std::vector<std::pair<int, SenderSessionMessenger::ReplyCallback>>*
replies) { … }
}
SessionMessenger::SessionMessenger(MessagePort& message_port,
std::string source_id,
ErrorCallback cb)
: … { … }
SessionMessenger::~SessionMessenger() { … }
Error SessionMessenger::SendMessage(const std::string& destination_id,
const std::string& namespace_,
const Json::Value& message_root) { … }
void SessionMessenger::ReportError(const Error& error) { … }
SenderSessionMessenger::SenderSessionMessenger(MessagePort& message_port,
std::string source_id,
std::string receiver_id,
ErrorCallback cb,
TaskRunner& task_runner)
: … { … }
void SenderSessionMessenger::SetHandler(ReceiverMessage::Type type,
ReplyCallback cb) { … }
void SenderSessionMessenger::ResetHandler(ReceiverMessage::Type type) { … }
Error SenderSessionMessenger::SendOutboundMessage(SenderMessage message) { … }
Error SenderSessionMessenger::SendRpcMessage(
const std::vector<uint8_t>& message) { … }
Error SenderSessionMessenger::SendRequest(SenderMessage message,
ReceiverMessage::Type reply_type,
ReplyCallback cb) { … }
void SenderSessionMessenger::OnMessage(const std::string& source_id,
const std::string& message_namespace,
const std::string& message) { … }
void SenderSessionMessenger::OnError(const Error& error) { … }
ReceiverSessionMessenger::ReceiverSessionMessenger(MessagePort& message_port,
std::string source_id,
ErrorCallback cb)
: … { … }
void ReceiverSessionMessenger::SetHandler(SenderMessage::Type type,
RequestCallback cb) { … }
void ReceiverSessionMessenger::ResetHandler(SenderMessage::Type type) { … }
Error ReceiverSessionMessenger::SendMessage(const std::string& source_id,
ReceiverMessage message) { … }
void ReceiverSessionMessenger::OnMessage(const std::string& source_id,
const std::string& message_namespace,
const std::string& message) { … }
void ReceiverSessionMessenger::OnError(const Error& error) { … }
}