1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CAST_COMMON_CHANNEL_NAMESPACE_ROUTER_H_ 6 #define CAST_COMMON_CHANNEL_NAMESPACE_ROUTER_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "cast/common/channel/cast_message_handler.h" 12 #include "cast/common/channel/proto/cast_channel.pb.h" 13 14 namespace openscreen { 15 namespace cast { 16 17 class NamespaceRouter final : public CastMessageHandler { 18 public: 19 NamespaceRouter(); 20 ~NamespaceRouter() override; 21 22 void AddNamespaceHandler(std::string namespace_, CastMessageHandler* handler); 23 void RemoveNamespaceHandler(const std::string& namespace_); 24 25 // CastMessageHandler overrides. 26 void OnMessage(VirtualConnectionRouter* router, 27 CastSocket* socket, 28 ::cast::channel::CastMessage message) override; 29 30 private: 31 std::map<std::string /* namespace */, CastMessageHandler*> handlers_; 32 }; 33 34 } // namespace cast 35 } // namespace openscreen 36 37 #endif // CAST_COMMON_CHANNEL_NAMESPACE_ROUTER_H_ 38