TDME2 1.9.121
UDPClientMessage.h
Go to the documentation of this file.
1#pragma once
2
3#include <sstream>
4#include <string>
5
6#include <tdme/tdme.h>
8
9using std::string;
10using std::stringstream;
11
12/**
13 * UDP client message
14 * @author Andreas Drewke
15 */
17 friend UDPClient;
18
19public:
25 };
26
27 /**
28 * Parse
29 * @param message[512] message
30 * @param bytes bytes
31 */
32 static UDPClientMessage* parse(const char message[512], const size_t bytes);
33
34 /**
35 * Destructor
36 */
38
39 /**
40 * @return time
41 */
42 const uint64_t getTime();
43
44 /**
45 * @return message type
46 */
48
49 /**
50 * @return client id
51 */
52 const uint32_t getClientId();
53
54 /**
55 * @return message id
56 */
57 const uint32_t getMessageId();
58
59 /**
60 * @return retry count
61 */
62 const uint8_t getRetryCount();
63
64 /**
65 * @return retry time
66 */
67 const int64_t getRetryTime();
68
69 /**
70 * Mark message to be resend with increased retry count
71 */
72 void retry();
73
74 /**
75 * @return frame
76 */
77 stringstream* getFrame();
78
79 /**
80 * Generate datagram
81 */
82 void generate(char message[512], size_t& bytes);
83
84private:
85 /**
86 * Public constructor
87 * @param messageType message type
88 * @param clientId client id
89 * @param messageId message id
90 * @param retries retries
91 * @param frame frame
92 */
93 UDPClientMessage(const MessageType messageType, const uint32_t clientId, const uint32_t messageId, const uint8_t retries, stringstream* frame);
94
95 //
96 long time;
97 uint8_t retries;
99 uint32_t clientId;
100 uint32_t messageId;
101 stringstream* frame;
102};
void generate(char message[512], size_t &bytes)
Generate datagram.
void retry()
Mark message to be resend with increased retry count.
static UDPClientMessage * parse(const char message[512], const size_t bytes)
Parse.
UDPClientMessage(const MessageType messageType, const uint32_t clientId, const uint32_t messageId, const uint8_t retries, stringstream *frame)
Public constructor.