Adds immediate migration results
This commit is contained in:
2395 files changed
+357322
-2524
No files matched your search
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* (c) Copyright, Real-Time Innovations, 2024.
|
||||
* All rights reserved.
|
||||
*
|
||||
* No duplications, whole or partial, manual or electronic, may be made
|
||||
* without express written permission. Any such copies, or
|
||||
* revisions thereof, must display this notice unaltered.
|
||||
* This code contains trade secrets of Real-Time Innovations, Inc.
|
||||
*/
|
||||
|
||||
#ifndef WEBSOCKET_API_UTILS_H_
|
||||
#define WEBSOCKET_API_UTILS_H_
|
||||
|
||||
#include "dds_c/dds_c_printformat.h"
|
||||
#include <memory>
|
||||
|
||||
#include <rti/apputils/http/common/HttpException.hpp>
|
||||
|
||||
#define ERR_LOST_HEADER "Lost header"
|
||||
#define WEBSOCKET_RESPONSE_NAME "response"
|
||||
#define WEBSOCKET_HELLO_FAIL_HEADER "HELLO FAIL:"
|
||||
|
||||
namespace rti { namespace apputils { namespace websocket {
|
||||
|
||||
enum class WebSocketStateKind{
|
||||
UNKNOWN,
|
||||
CREATE,
|
||||
OPEN,
|
||||
READY,
|
||||
CLOSE
|
||||
};
|
||||
|
||||
enum class WebSocketContentType{
|
||||
UNKNOWN,
|
||||
JSON,
|
||||
XML
|
||||
};
|
||||
|
||||
inline DDS_PrintFormatKind to_print_format_kind(WebSocketContentType contentType) {
|
||||
return contentType == WebSocketContentType::JSON
|
||||
? DDS_JSON_PRINT_FORMAT
|
||||
: DDS_XML_PRINT_FORMAT;
|
||||
}
|
||||
|
||||
inline WebSocketContentType to_websocket_content_type(DDS_PrintFormatKind formatKind) {
|
||||
WebSocketContentType value = WebSocketContentType::UNKNOWN;
|
||||
switch (formatKind) {
|
||||
case DDS_JSON_PRINT_FORMAT:
|
||||
value = WebSocketContentType::JSON;
|
||||
break;
|
||||
case DDS_XML_PRINT_FORMAT:
|
||||
value = WebSocketContentType::XML;
|
||||
break;
|
||||
case DDS_DEFAULT_PRINT_FORMAT:
|
||||
value = WebSocketContentType::XML;
|
||||
break;
|
||||
default:
|
||||
value = WebSocketContentType::UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The RequestException class defines a exception will log an error message
|
||||
* via RTIWsddsLog_exeption or will just propagate a given return code
|
||||
* identifying the error and an error message. The class inherits from
|
||||
* Exception, as a result users can use familiar interfaces, such as what() to
|
||||
* get the error message. Also it have the request id to create the error
|
||||
* message to be sent.
|
||||
*/
|
||||
class RequestException : public rti::apputils::http::HttpException {
|
||||
public:
|
||||
RequestException(
|
||||
const char *throwing_context,
|
||||
rti::apputils::http::StatusCode error_code,
|
||||
const RTILogMessage *log_message,
|
||||
const char *method_name,
|
||||
...)
|
||||
: HttpException(throwing_context, error_code, log_message),
|
||||
method_name_(method_name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the method name that threw the exception.
|
||||
* @return Method name that threw the exception.
|
||||
*/
|
||||
const char * get_method_name() const
|
||||
{
|
||||
return method_name_;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *method_name_;
|
||||
};
|
||||
|
||||
}}} // namespace rti::webdds::websocket
|
||||
|
||||
#endif // WEBSOCKET_API_UTILS_H_
|
||||
Reference in new issue
Block a user