HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NET_WebAPIResponse.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: NET_WebAPIResponse.h
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __NET_WEBAPIRESPONSE_H__
13 #define __NET_WEBAPIRESPONSE_H__
14 
15 #include "NET_API.h"
16 
17 #include "NET_WebResponse.h"
18 #include "NET_WebTypes.h"
19 
20 #include <UT/UT_JSONValue.h>
21 #include <UT/UT_StringHolder.h>
22 #include <UT/UT_SGuid.h>
23 
25 {
26 public:
27  enum Type
28  {
30  WebSocket
31  };
32 
33  NET_WebAPIResponse() = default;
35 
36  void setAsHTTP(NET_HTTPResponse&& resp);
37  /// @brief Parse a websocket response.
38  ///
39  /// @param resp The response from a websocket api request.
40  ///
41  /// @return True if the parse was a success.
42  bool parseWebSocket(const UT_StringHolder& resp);
43 
48  // The body of the response
50 
51  const UT_JSONValue* json() { return myCommand; }
52  Type type() const { return myType; }
54  {
55  return myId.toString();
56  }
57  const UT_SGuid& id() const
58  {
59  return myId;
60  }
61 private:
62  Type myType;
63 
64 // ==========================================
65 // WebSocket specific data
66 // ==========================================
67  UT_JSONValue myJSON;
68  UT_SGuid myId;
69  UT_JSONValue* myCommand = nullptr;
70 };
71 
72 #endif // __NET_WEBAPIRESPONSE_H__
73 
UT_StringArray myCookies
const UT_SGuid & id() const
const UT_JSONValue * json()
NET_HTTPStatusCode myStatus
NET_HTTPStatusCode
#define NET_API
Definition: NET_API.h:9
NET_HTTPResponse::HeaderMap myHeaders
Response object used by a client from a response by a server.
UT_StringHolder myData
NET_HTTPResponse::Error myError
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
UT_StringHolder idToString() const