NymphRPC Remote Procedure Call Library
nymph_message.h
1 /*
2  nymph_message.h - Declares the NymphRPC Message class.
3 
4  Revision 0
5 
6  Notes:
7  -
8 
9  2017/06/24, Maya Posch : Initial version.
10  (c) Nyanko.ws
11 */
12 
13 
14 #pragma once
15 #ifndef NYMPH_MESSAGE_H
16 #define NYMPH_MESSAGE_H
17 
18 #include "nymph_types.h"
19 
20 #include <Poco/Poco.h>
21 
22 #include <vector>
23 
24 
25 enum {
26  NYMPH_MESSAGE_REPLY = 0x01, // Message is a reply.
27  NYMPH_MESSAGE_EXCEPTION = 0x02, // Message is an exception.
28  NYMPH_MESSAGE_CALLBACK = 0x04 // Message is a callback.
29 };
30 
31 
33  uint32_t id;
34  std::string value;
35 };
36 
37 
38 class NymphMessage {
39  std::vector<NymphType*> values;
40  uint32_t command;
41  uint32_t flags;
42  uint32_t methodId;
43  int state;
44  uint64_t messageId;
45  uint64_t responseId;
46  NymphException exception;
47  bool hasResult;
48  bool responseOwned;
49  std::string callbackName;
50  NymphType* response;
51  std::string loggerName;
52 
53 public:
54  NymphMessage();
55  NymphMessage(uint32_t methodId);
56  NymphMessage(std::string* binmsg);
57  ~NymphMessage();
58  bool addValue(NymphType* value);
59  bool finish(std::string &output);
60  int getState() { return state; }
61  void setInReplyTo(uint64_t msgId);
62  bool isCallback() { return flags & NYMPH_MESSAGE_CALLBACK; }
63  uint64_t getResponseId() { return responseId; }
64  uint64_t getMessageId() { return messageId; }
65  void setResultValue(NymphType* value);
66  NymphType* getResponse() { return response; responseOwned = false; }
67  std::vector<NymphType*> parameters() { return values; }
68  uint32_t getMethodId() { return methodId; }
69  NymphMessage* getReplyMessage();
70  NymphException getException() { return exception; }
71  std::string getCallbackName() { return callbackName; }
72  bool isReply() { return flags & NYMPH_MESSAGE_REPLY; }
73  bool isException() { return flags & NYMPH_MESSAGE_EXCEPTION; }
74  bool setException(int exceptionId, std::string value);
75  bool setCallback(std::string name);
76 };
77 
78 #endif
Definition: nymph_message.h:38
Definition: nymph_types.h:133
Definition: nymph_message.h:32