5.2. Endpoint

class eprosima::is::sh::websocket::Endpoint : public eprosima::is::FullSystem, public eprosima::is::ServiceClient

Represents a WebSocket endpoint for the Integration Service. The Endpoint class will be later specialized for client and server applications.

Subclassed by eprosima::is::sh::websocket::Client, eprosima::is::sh::websocket::Server

Public Functions

Endpoint(const std::string &name)

Constructor.

Parameters
  • name: The name given to this Endpoint instance. It will be used to identify logging traces.

bool configure(const core::RequiredTypes &types, const YAML::Node &configuration, TypeRegistry &type_registry) override

Inherited from SystemHandle.

bool okay() const = 0

Inherited from SystemHandle.

bool spin_once() = 0

Inherited from SystemHandle.

~Endpoint() = default

Destructor.

bool subscribe(const std::string &topic_name, const xtypes::DynamicType &message_type, TopicSubscriberSystem::SubscriptionCallback *callback, const YAML::Node &configuration) final override

Inherited from TopicSubscriberSystem.

bool is_internal_message(void *filter_handle) final override

Inherited from TopicSubscriberSystem.

std::shared_ptr<TopicPublisher> advertise(const std::string &topic_name, const xtypes::DynamicType &message_type, const YAML::Node &configuration) final override

Inherited from TopicPublisherSystem.

bool create_client_proxy(const std::string &service_name, const xtypes::DynamicType &service_type, ServiceClientSystem::RequestCallback *callback, const YAML::Node &configuration) final override

Inherited from ServiceClientSystem.

bool create_client_proxy(const std::string &service_name, const xtypes::DynamicType &request_type, const xtypes::DynamicType &reply_type, ServiceClientSystem::RequestCallback *callback, const YAML::Node &configuration) final override

Inherited from ServiceClientSystem.

std::shared_ptr<ServiceProvider> create_service_proxy(const std::string &service_name, const xtypes::DynamicType &service_type, const YAML::Node &configuration) final override

Inherited from ServiceProviderSystem.

std::shared_ptr<ServiceProvider> create_service_proxy(const std::string &service_name, const xtypes::DynamicType &request_type, const xtypes::DynamicType &reply_type, const YAML::Node &configuration) final override

Inherited from ServiceProviderSystem.

void startup_advertisement(const std::string &topic, const xtypes::DynamicType &message_type, const std::string &id, const YAML::Node &configuration)

Send out an advertisement the next time a connection is made.

Parameters
  • [in] topic: The topic name.

  • [in] message_type: The Dynamic Type message representation.

  • [in] id: The publisher ID.

  • [in] configuration: Additional configuration, in YAML format, required to advertise the topic.

void runtime_advertisement(const std::string &topic, const xtypes::DynamicType &message_type, const std::string &id, const YAML::Node &configuration) = 0

Send out an advertisement to all existing connections right away. This is for publication topics that are determined at runtime by topic templates.

Parameters
  • [in] topic: The topic name.

  • [in] message_type: The Dynamic Type message representation.

  • [in] id: The message ID.

  • [in] configuration: Additional configuration, in YAML format, required to advertise the topic.

bool publish(const std::string &topic, const xtypes::DynamicData &message)

Publish a message to a certain topic.

See

is::TopicPublisher.

Return

true if the publication was made, false otherwise.

Parameters
  • [in] topic: The topic name to publish to.

  • [in] message: The message data instance to be published.

void call_service(const std::string &service, const xtypes::DynamicData &request, ServiceClient &client, std::shared_ptr<void> call_handle)

Call a service.

See

is::ServiceProvider.

Parameters
  • [in] service: The name of the service to be called.

  • [in] request: Request message for the service.

  • [inout] client: The proxy for the client that is making the request.

  • [in] call_handle: A handle for the call.

void receive_response(std::shared_ptr<void> call_handle, const xtypes::DynamicData &response) final override

Inherited from ServiceClient.

void receive_topic_advertisement_ws(const std::string &topic_name, const xtypes::DynamicType &message_type, const std::string &id, std::shared_ptr<void> connection_handle)

Process an advertisement message. This step is required prior to publish operation.

Parameters
  • [in] topic_name: The name of the topic to be advertised.

  • [in] message_type: The type name of the topic to be advertised.

  • [in] id: The publisher ID.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_topic_unadvertisement_ws(const std::string &topic_name, const std::string &id, std::shared_ptr<void> connection_handle)

Process an unadvertisement message.

Parameters
  • [in] topic_name: The name of the topic to be unadvertised.

  • [in] id: The publisher ID.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_publication_ws(const std::string &topic_name, const xtypes::DynamicData &message, std::shared_ptr<void> connection_handle)

Process an publication.

Parameters
  • [in] topic_name: The name of the topic where the message will be published to.

  • [in] message: The message published.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_subscribe_request_ws(const std::string &topic_name, const xtypes::DynamicType *message_type, const std::string &id, std::shared_ptr<void> connection_handle)

Process a request for subscribing to a certain topic.

Parameters
  • [in] topic_name: The name of the topic where the subscription will be performed to.

  • [in] message_type: The dynamic type of the topic to get subscribed to.

  • [in] id: The identifier of the message.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_unsubscribe_request_ws(const std::string &topic_name, const std::string &id, std::shared_ptr<void> connection_handle)

Process a request for unsubscribing to a certain topic.

Parameters
  • [in] topic_name: The name of the topic where the subscription will be stopped.

  • [in] id: The identifier of the message.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_service_request_ws(const std::string &service_name, const xtypes::DynamicData &request, const std::string &id, std::shared_ptr<void> connection_handle)

Process a service request.

Parameters
  • [in] service_name: The name of the service.

  • [in] request: The request data.

  • [in] id: The service ID.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_service_advertisement_ws(const std::string &service_name, const xtypes::DynamicType &req_type, const xtypes::DynamicType &reply_type, std::shared_ptr<void> connection_handle)

Process a service advertisement. This is required prior to calling a service.

Parameters
  • [in] service_name: The name of the service.

  • [in] req_type: The request data type.

  • [in] reply_type: The reply data type.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_service_unadvertisement_ws(const std::string &service_name, const xtypes::DynamicType *service_type, std::shared_ptr<void> connection_handle)

Process a service unadvertisement. The service will no longer be available.

Parameters
  • [in] service_name: The name of the service.

  • [in] service_type: The service type. Usually refers to the request type.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

void receive_service_response_ws(const std::string &service_name, const xtypes::DynamicData &response, const std::string &id, std::shared_ptr<void> connection_handle)

Process a service response.

Parameters
  • [in] service_name: The name of the service.

  • [in] response: The response data.

  • [in] id: The service ID.

  • [in] connection_handle: Opaque pointer which identifies the current connection.

5.3. Client

class Client : public eprosima::is::sh::websocket::Endpoint

This class represents a WebSocket Client, which can be defined as an application that sends requests to a specific port and waits for the Server response.

It implements some of the Endpoint class methods.

5.4. Server

class Server : public eprosima::is::sh::websocket::Endpoint

This class represents a WebSocket Server, which can be defined as an application that listens to a specific port waiting for Client’s requests.

It implements some of the Endpoint class methods.