5.1. Encoding¶
-
class
eprosima::is::sh::websocket::Encoding¶ This interface class defines all the methods that must be implemented in order to create an encoding to be used to construct and interpret raw WebSocket messages.
eprosima::is::sh::websocket::JsonEncoding: Encoding implementation for message exchanging using JSON format.
Subclassed by eprosima::is::sh::websocket::JsonEncoding
Public Functions
Interpret an incoming WebSocket message.
- Parameters
[in] msg: The message to be interpreted.[in] endpoint: The target endpoint which will perform the actions specified by the message.[in] connection_handle: Opaque pointer which identifies the current connection.
-
std::string
encode_publication_msg(const std::string &topic_name, const std::string &topic_type, const std::string &id, const xtypes::DynamicData &msg) const = 0¶ Encode a publish message.
- Return
A string representation of the encoded publication message, ready to be sent using WebSocket.
- Parameters
[in] topic_name: The name of the topic where the message will be published to.[in] topic_type: The type name of the topic where the message will be published to.[in] id: The publisher ID.[in] msg: The message data to be published. This will be transformed to JSON format beforehand.
-
std::string
encode_service_response_msg(const std::string &service_name, const std::string &service_type, const std::string &id, const xtypes::DynamicData &response, bool result) const = 0¶ Encode a service response message.
- Return
A string representation of the encoded service response message, ready to be sent using WebSocket.
- Parameters
[in] service_name: The name of the service which is answering.[in] service_type: The type name of the service reply.[in] id: The service ID.[in] response: The message data containing the service response. This will be transformed to JSON format beforehand.[in] result: Indicates if the response was received or not from the service server.
-
std::string
encode_subscribe_msg(const std::string &topic_name, const std::string &message_type, const std::string &id, const YAML::Node &configuration) const = 0¶ Encode a subscription message.
- Return
A string representation of the encoded subscription message, ready to be sent using WebSocket.
- Parameters
[in] topic_name: The name of the topic to which the subscription will be performed.[in] message_type: The type name of the topic to which the subscription will be performed.[in] id: The subscriber ID.[in] configuration: Additional configuration that might be required for the subscription operation.
-
std::string
encode_advertise_msg(const std::string &topic_name, const std::string &message_type, const std::string &id, const YAML::Node &configuration) const = 0¶ Encode an advertisement message. This step is required prior to publish operation.
- Return
A string representation of the encoded advertise message, ready to be sent using WebSocket.
- Parameters
[in] topic_name: The name of the topic to which the advertisement will be performed.[in] message_type: The type name of the topic to which the advertisement will be performed.[in] id: The publisher ID.[in] configuration: Additional configuration that might be required for the advertise operation.
-
std::string
encode_call_service_msg(const std::string &service_name, const std::string &service_type, const xtypes::DynamicData &service_request, const std::string &id, const YAML::Node &configuration) const = 0¶ Encode a call service message.
- Return
A string representation of the encoded call service message, ready to be sent using WebSocket.
- Parameters
[in] service_name: The name of service to be called.[in] service_type: The type name of the service to be called.[in] service_request: The data of the request message. This will be transformed to JSON format beforehand.[in] id: The service ID.[in] configuration: Additional configuration that might be required for the call service operation.
-
std::string
encode_advertise_service_msg(const std::string &service_name, const std::string &request_type, const std::string &reply_type, const std::string &id, const YAML::Node &configuration) const = 0¶ Encode an advertise service message. This step is required prior to service call operations.
- Return
A string representation of the encoded service advertise message, ready to be sent using WebSocket.
- Parameters
[in] service_name: The name of the service to which the advertisement will be performed.[in] request_type: The request type name of the service to which the advertisement will be performed.[in] reply_type: The reply type name of the service to which the advertisement will be performed.[in] id: The service ID.[in] configuration: Additional configuration that might be required for the advertise operation.
-
bool
add_type(const xtypes::DynamicType &type, const std::string &type_name = "")¶ Add a type to the types database.
- Return
trueif the type was correctly added, orfalseotherwise.- Parameters
[in] type: The dynamic type to be added.[in] type_name: The type name.