aboutsummaryrefslogtreecommitdiff
path: root/osp/public
diff options
context:
space:
mode:
Diffstat (limited to 'osp/public')
-rw-r--r--osp/public/BUILD.gn2
-rw-r--r--osp/public/mdns_service_listener_factory.h5
-rw-r--r--osp/public/network_service_manager.h8
-rw-r--r--osp/public/presentation/presentation_connection.h4
-rw-r--r--osp/public/request_response_handler.h4
-rw-r--r--osp/public/service_info.h2
-rw-r--r--osp/public/service_publisher.cc23
-rw-r--r--osp/public/service_publisher.h38
-rw-r--r--osp/public/service_publisher_factory.h (renamed from osp/public/mdns_service_publisher_factory.h)8
9 files changed, 46 insertions, 48 deletions
diff --git a/osp/public/BUILD.gn b/osp/public/BUILD.gn
index cc915c60..3606dcd5 100644
--- a/osp/public/BUILD.gn
+++ b/osp/public/BUILD.gn
@@ -11,7 +11,6 @@ source_set("public") {
"endpoint_request_ids.cc",
"endpoint_request_ids.h",
"mdns_service_listener_factory.h",
- "mdns_service_publisher_factory.h",
"message_demuxer.h",
"network_metrics.h",
"network_service_manager.h",
@@ -35,6 +34,7 @@ source_set("public") {
"service_listener.h",
"service_publisher.cc",
"service_publisher.h",
+ "service_publisher_factory.h",
"timestamp.h",
]
diff --git a/osp/public/mdns_service_listener_factory.h b/osp/public/mdns_service_listener_factory.h
index 663d060f..fa33f54f 100644
--- a/osp/public/mdns_service_listener_factory.h
+++ b/osp/public/mdns_service_listener_factory.h
@@ -8,6 +8,7 @@
#include <memory>
#include "osp/public/service_listener.h"
+#include "util/osp_logging.h"
namespace openscreen {
@@ -25,7 +26,9 @@ class MdnsServiceListenerFactory {
static std::unique_ptr<ServiceListener> Create(
const MdnsServiceListenerConfig& config,
ServiceListener::Observer* observer,
- TaskRunner* task_runner);
+ TaskRunner* task_runner) {
+ OSP_NOTREACHED();
+ }
};
} // namespace osp
diff --git a/osp/public/network_service_manager.h b/osp/public/network_service_manager.h
index 8289e178..b1a225c4 100644
--- a/osp/public/network_service_manager.h
+++ b/osp/public/network_service_manager.h
@@ -28,7 +28,7 @@ class NetworkServiceManager final {
// be passed for services not provided by the embedder.
static NetworkServiceManager* Create(
std::unique_ptr<ServiceListener> mdns_listener,
- std::unique_ptr<ServicePublisher> mdns_publisher,
+ std::unique_ptr<ServicePublisher> service_publisher,
std::unique_ptr<ProtocolConnectionClient> connection_client,
std::unique_ptr<ProtocolConnectionServer> connection_server);
@@ -47,7 +47,7 @@ class NetworkServiceManager final {
// Returns an instance of the mDNS receiver publisher, or nullptr if not
// provided.
- ServicePublisher* GetMdnsServicePublisher();
+ ServicePublisher* GetServicePublisher();
// Returns an instance of the protocol connection client, or nullptr if not
// provided.
@@ -60,14 +60,14 @@ class NetworkServiceManager final {
private:
NetworkServiceManager(
std::unique_ptr<ServiceListener> mdns_listener,
- std::unique_ptr<ServicePublisher> mdns_publisher,
+ std::unique_ptr<ServicePublisher> service_publisher,
std::unique_ptr<ProtocolConnectionClient> connection_client,
std::unique_ptr<ProtocolConnectionServer> connection_server);
~NetworkServiceManager();
std::unique_ptr<ServiceListener> mdns_listener_;
- std::unique_ptr<ServicePublisher> mdns_publisher_;
+ std::unique_ptr<ServicePublisher> service_publisher_;
std::unique_ptr<ProtocolConnectionClient> connection_client_;
std::unique_ptr<ProtocolConnectionServer> connection_server_;
};
diff --git a/osp/public/presentation/presentation_connection.h b/osp/public/presentation/presentation_connection.h
index ee0cff1b..4ea37ce7 100644
--- a/osp/public/presentation/presentation_connection.h
+++ b/osp/public/presentation/presentation_connection.h
@@ -62,7 +62,6 @@ class Connection {
class Delegate {
public:
Delegate() = default;
- virtual ~Delegate() = default;
// State changes.
virtual void OnConnected() = 0;
@@ -85,6 +84,9 @@ class Connection {
// A binary message was received.
virtual void OnBinaryMessage(const std::vector<uint8_t>& data) = 0;
+ protected:
+ virtual ~Delegate() = default;
+
private:
OSP_DISALLOW_COPY_AND_ASSIGN(Delegate);
};
diff --git a/osp/public/request_response_handler.h b/osp/public/request_response_handler.h
index de783efc..0ae97f88 100644
--- a/osp/public/request_response_handler.h
+++ b/osp/public/request_response_handler.h
@@ -59,12 +59,14 @@ class RequestResponseHandler : public MessageDemuxer::MessageCallback {
public:
class Delegate {
public:
- virtual ~Delegate() = default;
virtual void OnMatchedResponse(RequestT* request,
typename RequestT::ResponseMsgType* response,
uint64_t endpoint_id) = 0;
virtual void OnError(RequestT* request, Error error) = 0;
+
+ protected:
+ virtual ~Delegate() = default;
};
explicit RequestResponseHandler(Delegate* delegate) : delegate_(delegate) {}
diff --git a/osp/public/service_info.h b/osp/public/service_info.h
index e486052c..7c95ff2e 100644
--- a/osp/public/service_info.h
+++ b/osp/public/service_info.h
@@ -14,6 +14,8 @@
namespace openscreen {
namespace osp {
+constexpr char kOpenScreenServiceName[] = "_openscreen._udp";
+
// This contains canonical information about a specific Open Screen service
// found on the network via our discovery mechanism (mDNS).
struct ServiceInfo {
diff --git a/osp/public/service_publisher.cc b/osp/public/service_publisher.cc
index 3a8e70b7..2268f2d1 100644
--- a/osp/public/service_publisher.cc
+++ b/osp/public/service_publisher.cc
@@ -7,26 +7,25 @@
namespace openscreen {
namespace osp {
-ServicePublisherError::ServicePublisherError() = default;
-ServicePublisherError::ServicePublisherError(Code error,
- const std::string& message)
- : error(error), message(message) {}
-ServicePublisherError::ServicePublisherError(
- const ServicePublisherError& other) = default;
-ServicePublisherError::~ServicePublisherError() = default;
-
-ServicePublisherError& ServicePublisherError::operator=(
- const ServicePublisherError& other) = default;
-
ServicePublisher::Metrics::Metrics() = default;
ServicePublisher::Metrics::~Metrics() = default;
ServicePublisher::Config::Config() = default;
ServicePublisher::Config::~Config() = default;
+bool ServicePublisher::Config::IsValid() const {
+ return !friendly_name.empty() && !service_instance_name.empty() &&
+ connection_server_port > 0 && !network_interfaces.empty();
+}
+
+ServicePublisher::~ServicePublisher() = default;
+
+void ServicePublisher::SetConfig(const Config& config) {
+ config_ = config;
+}
+
ServicePublisher::ServicePublisher(Observer* observer)
: state_(State::kStopped), observer_(observer) {}
-ServicePublisher::~ServicePublisher() = default;
} // namespace osp
} // namespace openscreen
diff --git a/osp/public/service_publisher.h b/osp/public/service_publisher.h
index b31f59fc..190d22df 100644
--- a/osp/public/service_publisher.h
+++ b/osp/public/service_publisher.h
@@ -10,30 +10,13 @@
#include <vector>
#include "osp/public/timestamp.h"
-#include "platform/api/network_interface.h"
+#include "platform/base/error.h"
+#include "platform/base/interface_info.h"
#include "platform/base/macros.h"
namespace openscreen {
namespace osp {
-// Used to report an error from a ServiceListener implementation.
-struct ServicePublisherError {
- // TODO(mfoltz): Add additional error types, as implementations progress.
- enum class Code {
- kNone = 0,
- };
-
- ServicePublisherError();
- ServicePublisherError(Code error, const std::string& message);
- ServicePublisherError(const ServicePublisherError& other);
- ~ServicePublisherError();
-
- ServicePublisherError& operator=(const ServicePublisherError& other);
-
- Code error;
- std::string message;
-};
-
class ServicePublisher {
public:
enum class State {
@@ -74,7 +57,7 @@ class ServicePublisher {
virtual void OnSuspended() = 0;
// Reports an error.
- virtual void OnError(ServicePublisherError) = 0;
+ virtual void OnError(Error) = 0;
// Reports metrics.
virtual void OnMetrics(Metrics) = 0;
@@ -103,15 +86,21 @@ class ServicePublisher {
// configured in the ProtocolConnectionServer.
uint16_t connection_server_port = 0;
- // A list of network interface names that the publisher should use.
+ // A list of network interfaces that the publisher should use.
// By default, all enabled Ethernet and WiFi interfaces are used.
// This configuration must be identical to the interfaces configured
// in the ScreenConnectionServer.
- std::vector<NetworkInterfaceIndex> network_interface_indices;
+ std::vector<InterfaceInfo> network_interfaces;
+
+ // Returns true if the config object is valid.
+ bool IsValid() const;
};
virtual ~ServicePublisher();
+ // Sets the service configuration for this publisher.
+ virtual void SetConfig(const Config& config);
+
// Starts publishing this service using the config object.
// Returns true if state() == kStopped and the service will be started, false
// otherwise.
@@ -139,14 +128,15 @@ class ServicePublisher {
State state() const { return state_; }
// Returns the last error reported by this publisher.
- ServicePublisherError last_error() const { return last_error_; }
+ Error last_error() const { return last_error_; }
protected:
explicit ServicePublisher(Observer* observer);
State state_;
- ServicePublisherError last_error_;
+ Error last_error_;
Observer* observer_;
+ Config config_;
OSP_DISALLOW_COPY_AND_ASSIGN(ServicePublisher);
};
diff --git a/osp/public/mdns_service_publisher_factory.h b/osp/public/service_publisher_factory.h
index 075137a7..93193d03 100644
--- a/osp/public/mdns_service_publisher_factory.h
+++ b/osp/public/service_publisher_factory.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef OSP_PUBLIC_MDNS_SERVICE_PUBLISHER_FACTORY_H_
-#define OSP_PUBLIC_MDNS_SERVICE_PUBLISHER_FACTORY_H_
+#ifndef OSP_PUBLIC_SERVICE_PUBLISHER_FACTORY_H_
+#define OSP_PUBLIC_SERVICE_PUBLISHER_FACTORY_H_
#include <memory>
@@ -15,7 +15,7 @@ class TaskRunner;
namespace osp {
-class MdnsServicePublisherFactory {
+class ServicePublisherFactory {
public:
static std::unique_ptr<ServicePublisher> Create(
const ServicePublisher::Config& config,
@@ -26,4 +26,4 @@ class MdnsServicePublisherFactory {
} // namespace osp
} // namespace openscreen
-#endif // OSP_PUBLIC_MDNS_SERVICE_PUBLISHER_FACTORY_H_
+#endif // OSP_PUBLIC_SERVICE_PUBLISHER_FACTORY_H_