GoPxL SDK

- Home
- Files
- Namespace

GoDiscoveryClient.h
Go to the documentation of this file.
1
9 #ifndef GO_PXL_SDK_GODISCOVERYCLIENT_H
10 #define GO_PXL_SDK_GODISCOVERYCLIENT_H
11
12 #include <kApi/kApi.h>
13 #include <GoPxLSdk/GoJson.h>
14 #include <GoPxLSdk/GoInstance.h>
15 #include <GoApi/Exception.h>
16
17 class GoDiscoveryClientTests;
18
19 namespace GoPxLSdk
20 {
21 const k64u GOPXL_BROADCAST_SIGNATURE = 0x4C58504F47494D4C; // "LMIGOPXL"
22 const k32u GOPXL_RESERVED_PORT_DISCOVERY_PROTOCOL = 3320;
23 const k64u GOPXL_DISCOVERY_MESSAGE_DISCOVER = 0x0001;
24 const k64u GOPXL_DISCOVERY_MESSAGE_ANNOUNCE = 0x1001;
25 const kSize MAX_MESSAGE_SIZE = 1536;
26 const kSSize CLIENT_BUFFER_SIZE = 1536;
27 const kSSize CLIENT_SOCKET_SIZE = -1;
28
29 const std::string GOPXL_DISCOVERY_SERIAL_NUMBER = "SerialNumber";
30 const std::string GOPXL_DISCOVERY_DEVICE_MODEL = "DeviceModel";
31 const std::string GOPXL_DISCOVERY_APP_NAME = "AppName";
32 const std::string GOPXL_DISCOVERY_APP_ID = "AppId";
33 const std::string GOPXL_DISCOVERY_APP_VERSION = "AppVersion";
34 const std::string GOPXL_DISCOVERY_CONTROL_PORT = "ControlPort";
35 const std::string GOPXL_DISCOVERY_WEB_PORT = "WebPort";
36 const std::string GOPXL_DISCOVERY_GDP_PORT = "GdpPort";
37 const std::string GOPXL_DISCOVERY_ADDRESS = "Address";
38 const std::string GOPXL_DISCOVERY_MASK = "Mask";
39 const std::string GOPXL_DISCOVERY_GATEWAY = "Gateway";
40 const std::string GOPXL_DISCOVERY_DHCP = "Dhcp";
41 const std::string GOPXL_DISCOVERY_IS_REMOTE = "IsRemote";
42 const std::string GOPXL_DISCOVERY_ADDRESS_CONFLICT = "AddressConflict";
43
44 // Message request that is sent to the discovery server.
45 struct DiscoveryBroadcastHeader
46 {
47 k64u length;
48 k64u messageId;
49 k64u signature;
50 };
51
52 // Message header of the response that the discovery server sends back
53 // to discovery client.
54 struct DiscoveryServerHeader
55 {
56 k64u length;
57 k64u messageId;
58 k64u signature;
59 k64u messageStatus;
60 };
61
62 class GoPxLSdkClass GoDiscoveryClient
63 {
64 friend class ::GoDiscoveryClientTests;
65
66 public:
73 GoDiscoveryClient() = default;
74 ~GoDiscoveryClient() = default;
75
84 void BlockingDiscover(k64u timeoutInMilliseconds);
85
93 const std::vector<GoInstance>& InstanceList();
94
105 const GoInstance* Instance(std::string ipAddress, k32u webPort);
106
107 private:
108
117 void ConstructReceiver(kUdpClient* receiver);
118
128 void ConstructSender(kUdpClient* sender, kIpAddress address);
129
139 void Broadcast(const void* data, k32u length);
140
150 void ParseReply(Byte bytes[]);
151
152 std::vector<GoInstance> instances;
153 };
154
155 }
156
157 #endif
GoPxLSdkClass
#define GoPxLSdkClass
Definition: Def.h:35
GoPxLSdk::GOPXL_DISCOVERY_SERIAL_NUMBER
const std::string GOPXL_DISCOVERY_SERIAL_NUMBER
Definition: GoDiscoveryClient.h:29
GoPxLSdk::GoDiscoveryClient
Definition: GoDiscoveryClient.h:62
GoPxLSdk::GOPXL_DISCOVERY_WEB_PORT
const std::string GOPXL_DISCOVERY_WEB_PORT
Definition: GoDiscoveryClient.h:35
GoPxLSdk::GOPXL_DISCOVERY_GDP_PORT
const std::string GOPXL_DISCOVERY_GDP_PORT
Definition: GoDiscoveryClient.h:36
GoPxLSdk::GOPXL_DISCOVERY_DHCP
const std::string GOPXL_DISCOVERY_DHCP
Definition: GoDiscoveryClient.h:40
GoPxLSdk::GOPXL_DISCOVERY_GATEWAY
const std::string GOPXL_DISCOVERY_GATEWAY
Definition: GoDiscoveryClient.h:39
GoPxLSdk::GOPXL_BROADCAST_SIGNATURE
const k64u GOPXL_BROADCAST_SIGNATURE
Definition: GoDiscoveryClient.h:21
GoPxLSdk::DiscoveryServerHeader::messageId
k64u messageId
Definition: GoDiscoveryClient.h:57
GoPxLSdk::DiscoveryBroadcastHeader
Definition: GoDiscoveryClient.h:45
GoPxLSdk::GoInstance
Definition: GoInstance.h:17
GoPxLSdk::GOPXL_DISCOVERY_MASK
const std::string GOPXL_DISCOVERY_MASK
Definition: GoDiscoveryClient.h:38
GoPxLSdk::DiscoveryServerHeader
Definition: GoDiscoveryClient.h:54
GoPxLSdk::CLIENT_BUFFER_SIZE
const kSSize CLIENT_BUFFER_SIZE
Definition: GoDiscoveryClient.h:26
GoPxLSdk::DiscoveryServerHeader::signature
k64u signature
Definition: GoDiscoveryClient.h:58
GoPxLSdk::MAX_MESSAGE_SIZE
const kSize MAX_MESSAGE_SIZE
Definition: GoDiscoveryClient.h:25
GoPxLSdk::GOPXL_DISCOVERY_DEVICE_MODEL
const std::string GOPXL_DISCOVERY_DEVICE_MODEL
Definition: GoDiscoveryClient.h:30
GoPxLSdk::GOPXL_DISCOVERY_ADDRESS
const std::string GOPXL_DISCOVERY_ADDRESS
Definition: GoDiscoveryClient.h:37
GoPxLSdk::DiscoveryBroadcastHeader::messageId
k64u messageId
Definition: GoDiscoveryClient.h:48
GoPxLSdk::GOPXL_DISCOVERY_IS_REMOTE
const std::string GOPXL_DISCOVERY_IS_REMOTE
Definition: GoDiscoveryClient.h:41
GoPxLSdk::GOPXL_DISCOVERY_APP_ID
const std::string GOPXL_DISCOVERY_APP_ID
Definition: GoDiscoveryClient.h:32
GoJson.h
GoPxLSdk::GOPXL_DISCOVERY_APP_NAME
const std::string GOPXL_DISCOVERY_APP_NAME
Definition: GoDiscoveryClient.h:31
GoInstance.h
GoPxLSdk::DiscoveryServerHeader::messageStatus
k64u messageStatus
Definition: GoDiscoveryClient.h:59
GoPxLSdk::GOPXL_DISCOVERY_MESSAGE_ANNOUNCE
const k64u GOPXL_DISCOVERY_MESSAGE_ANNOUNCE
Definition: GoDiscoveryClient.h:24
GoPxLSdk::GOPXL_RESERVED_PORT_DISCOVERY_PROTOCOL
const k32u GOPXL_RESERVED_PORT_DISCOVERY_PROTOCOL
Definition: GoDiscoveryClient.h:22
GoPxLSdk::DiscoveryServerHeader::length
k64u length
Definition: GoDiscoveryClient.h:56
GoPxLSdk::GOPXL_DISCOVERY_ADDRESS_CONFLICT
const std::string GOPXL_DISCOVERY_ADDRESS_CONFLICT
Definition: GoDiscoveryClient.h:42
GoPxLSdk::GOPXL_DISCOVERY_MESSAGE_DISCOVER
const k64u GOPXL_DISCOVERY_MESSAGE_DISCOVER
Definition: GoDiscoveryClient.h:23
GoPxLSdk::DiscoveryBroadcastHeader::signature
k64u signature
Definition: GoDiscoveryClient.h:49
GoPxLSdk::Byte
kByte Byte
Definition: Def.h:48
GoPxLSdk::GOPXL_DISCOVERY_APP_VERSION
const std::string GOPXL_DISCOVERY_APP_VERSION
Definition: GoDiscoveryClient.h:33
GoPxLSdk
Definition: Def.h:46
GoPxLSdk::GOPXL_DISCOVERY_CONTROL_PORT
const std::string GOPXL_DISCOVERY_CONTROL_PORT
Definition: GoDiscoveryClient.h:34
GoPxLSdk::CLIENT_SOCKET_SIZE
const kSSize CLIENT_SOCKET_SIZE
Definition: GoDiscoveryClient.h:27
GoPxLSdk::DiscoveryBroadcastHeader::length
k64u length
Definition: GoDiscoveryClient.h:47