diff options
author | Yuri Wiitala <miu@chromium.org> | 2020-10-02 16:15:18 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-02 23:48:00 +0000 |
commit | af79da9ee416a7fa259e5e0d264ca92af1bd2fcc (patch) | |
tree | f673a9058f01dd93d090e4307153369ed749faa3 /cast/sender | |
parent | 8e5f2c0fe3e8f0a297a404d38f8d229d93a0325c (diff) | |
download | openscreen-af79da9ee416a7fa259e5e0d264ca92af1bd2fcc.tar.gz |
[Cast Channel] Add broadcast routing in VirtualConnectionRouter.
Replaces TODO comments with the implementation. :)
This change is needed for a soon-upcoming patch that will introduce a
basic Cast Agent (service for handling Cast V2 Application Control
messages) for a Cast Receiver.
The CastMessageHandler interface API contract was adjusted to allow a
nullptr CastSocket* argument, when a broadcast message comes from a
local peer instead of a remote sender.
Bug: b/169453993
Change-Id: Idbc698336e01022b8e7090498e882c66bb4922b0
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2433087
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast/sender')
-rw-r--r-- | cast/sender/cast_platform_client.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cast/sender/cast_platform_client.cc b/cast/sender/cast_platform_client.cc index 4d59c65b..224a58a4 100644 --- a/cast/sender/cast_platform_client.cc +++ b/cast/sender/cast_platform_client.cc @@ -4,7 +4,9 @@ #include "cast/sender/cast_platform_client.h" +#include <memory> #include <random> +#include <utility> #include "absl/strings/str_cat.h" #include "cast/common/channel/virtual_connection_manager.h" @@ -22,6 +24,8 @@ static constexpr std::chrono::seconds kRequestTimeout = std::chrono::seconds(5); namespace { +// TODO(miu): This is duplicated in another teammate's WIP CL. De-dupe this by +// placing the utility in cast/common. std::string MakeRandomSenderId() { static auto& rd = *new std::random_device(); static auto& gen = *new std::mt19937(rd()); @@ -149,8 +153,9 @@ void CastPlatformClient::OnMessage(VirtualConnectionRouter* router, if (request_id) { auto entry = std::find_if( socket_id_by_device_id_.begin(), socket_id_by_device_id_.end(), - [socket](const std::pair<std::string, int>& entry) { - return entry.second == socket->socket_id(); + [socket_id = + ToCastSocketId(socket)](const std::pair<std::string, int>& entry) { + return entry.second == socket_id; }); if (entry != socket_id_by_device_id_.end()) { HandleResponse(entry->first, request_id.value(), dict); |