Initial project snapshot
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
#include "rdp_worker/adapter/adapter_event_router.hpp"
|
||||
|
||||
#include "rdp_worker/common/json.hpp"
|
||||
|
||||
namespace rdp_worker::adapter {
|
||||
|
||||
namespace {
|
||||
|
||||
AdapterEventDescriptor MakeDescriptor(AdapterChannel channel,
|
||||
std::string_view type,
|
||||
bool adapter_origin) {
|
||||
return AdapterEventDescriptor{
|
||||
channel,
|
||||
type,
|
||||
adapter_origin,
|
||||
IsReliable(channel),
|
||||
IsDroppable(channel),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AdapterEventDescriptor AdapterEventRouter::DescribeRenderNotification(
|
||||
const runtime::RenderNotification& notification) const {
|
||||
if (notification.type == "session_frame") {
|
||||
const auto update_kind = common::GetString(notification.payload, "frame_update_kind").value_or("full");
|
||||
return MakeDescriptor(
|
||||
AdapterChannel::kDisplay,
|
||||
update_kind == "region" ? "display.region_bgra" : "display.baseline_full_bgra",
|
||||
true);
|
||||
}
|
||||
|
||||
if (notification.type == "session_cursor_updated") {
|
||||
return MakeDescriptor(AdapterChannel::kCursor, "cursor.update", true);
|
||||
}
|
||||
|
||||
if (notification.type == "session_render_resized") {
|
||||
return MakeDescriptor(AdapterChannel::kDisplay, "display.resize", true);
|
||||
}
|
||||
|
||||
if (notification.type == "session_render_dirty") {
|
||||
return MakeDescriptor(AdapterChannel::kDisplay, "display.dirty", true);
|
||||
}
|
||||
|
||||
return MakeDescriptor(AdapterChannel::kTelemetry, notification.type, true);
|
||||
}
|
||||
|
||||
AdapterEventDescriptor AdapterEventRouter::DescribeClipboardNotification(
|
||||
const runtime::ClipboardNotification&) const {
|
||||
return MakeDescriptor(AdapterChannel::kClipboard, "clipboard.server_text", true);
|
||||
}
|
||||
|
||||
AdapterEventDescriptor AdapterEventRouter::DescribeClientEnvelope(std::string_view envelope_type,
|
||||
std::string_view payload_kind,
|
||||
std::string_view payload_action) const {
|
||||
if (envelope_type == "input") {
|
||||
if (payload_kind == "mouse" && payload_action == "move") {
|
||||
return MakeDescriptor(AdapterChannel::kInput, "input.pointer_move", false);
|
||||
}
|
||||
if (payload_kind == "mouse") {
|
||||
return MakeDescriptor(AdapterChannel::kInput, "input.pointer", false);
|
||||
}
|
||||
if (payload_kind == "keyboard") {
|
||||
return MakeDescriptor(AdapterChannel::kInput, "input.keyboard", false);
|
||||
}
|
||||
if (payload_kind == "focus") {
|
||||
return MakeDescriptor(AdapterChannel::kInput, "input.focus", false);
|
||||
}
|
||||
return MakeDescriptor(AdapterChannel::kInput, "input.unknown", false);
|
||||
}
|
||||
|
||||
if (envelope_type == "clipboard") {
|
||||
return MakeDescriptor(AdapterChannel::kClipboard, "clipboard.client_text", false);
|
||||
}
|
||||
|
||||
if (envelope_type == "file_upload") {
|
||||
return MakeDescriptor(AdapterChannel::kFileTransfer, "file_upload.client_to_server", false);
|
||||
}
|
||||
|
||||
if (envelope_type == "control") {
|
||||
return MakeDescriptor(AdapterChannel::kControl, "control.command", false);
|
||||
}
|
||||
|
||||
return MakeDescriptor(AdapterChannel::kTelemetry, envelope_type, false);
|
||||
}
|
||||
|
||||
std::string AdapterEventDescriptorLogLine(const AdapterEventDescriptor& descriptor) {
|
||||
std::string line;
|
||||
line.reserve(160);
|
||||
line += "adapter_event channel=";
|
||||
line += ChannelName(descriptor.channel);
|
||||
line += " type=";
|
||||
line += descriptor.normalized_type;
|
||||
line += " origin=";
|
||||
line += descriptor.adapter_origin ? "adapter" : "client";
|
||||
line += " reliable=";
|
||||
line += descriptor.reliable ? "true" : "false";
|
||||
line += " droppable=";
|
||||
line += descriptor.droppable ? "true" : "false";
|
||||
return line;
|
||||
}
|
||||
|
||||
} // namespace rdp_worker::adapter
|
||||
|
||||
Reference in New Issue
Block a user