GoPxL SDK
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"
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.
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.
55 {
56  k64u length;
57  k64u messageId;
58  k64u signature;
60 };
61 
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
const k16u GOPXL_RESERVED_PORT_DISCOVERY_PROTOCOL
Definition: GoDiscoveryClient.h:22
#define GoPxLSdkClass
Definition: Def.h:35
const std::string GOPXL_DISCOVERY_SERIAL_NUMBER
Definition: GoDiscoveryClient.h:29
Definition: GoDiscoveryClient.h:62
const std::string GOPXL_DISCOVERY_WEB_PORT
Definition: GoDiscoveryClient.h:35
const std::string GOPXL_DISCOVERY_GDP_PORT
Definition: GoDiscoveryClient.h:36
const std::string GOPXL_DISCOVERY_DHCP
Definition: GoDiscoveryClient.h:40
const std::string GOPXL_DISCOVERY_GATEWAY
Definition: GoDiscoveryClient.h:39
const k64u GOPXL_BROADCAST_SIGNATURE
Definition: GoDiscoveryClient.h:21
k64u messageId
Definition: GoDiscoveryClient.h:57
Definition: GoDiscoveryClient.h:45
Definition: GoInstance.h:17
const std::string GOPXL_DISCOVERY_MASK
Definition: GoDiscoveryClient.h:38
Definition: GoDiscoveryClient.h:54
const kSSize CLIENT_BUFFER_SIZE
Definition: GoDiscoveryClient.h:26
k64u signature
Definition: GoDiscoveryClient.h:58
const kSize MAX_MESSAGE_SIZE
Definition: GoDiscoveryClient.h:25
const std::string GOPXL_DISCOVERY_DEVICE_MODEL
Definition: GoDiscoveryClient.h:30
const std::string GOPXL_DISCOVERY_ADDRESS
Definition: GoDiscoveryClient.h:37
k64u messageId
Definition: GoDiscoveryClient.h:48
const std::string GOPXL_DISCOVERY_IS_REMOTE
Definition: GoDiscoveryClient.h:41
const std::string GOPXL_DISCOVERY_APP_ID
Definition: GoDiscoveryClient.h:32
const std::string GOPXL_DISCOVERY_APP_NAME
Definition: GoDiscoveryClient.h:31
k64u messageStatus
Definition: GoDiscoveryClient.h:59
const k64u GOPXL_DISCOVERY_MESSAGE_ANNOUNCE
Definition: GoDiscoveryClient.h:24
k64u length
Definition: GoDiscoveryClient.h:56
const std::string GOPXL_DISCOVERY_ADDRESS_CONFLICT
Definition: GoDiscoveryClient.h:42
const k64u GOPXL_DISCOVERY_MESSAGE_DISCOVER
Definition: GoDiscoveryClient.h:23
k64u signature
Definition: GoDiscoveryClient.h:49
kByte Byte
Definition: Def.h:48
const std::string GOPXL_DISCOVERY_APP_VERSION
Definition: GoDiscoveryClient.h:33
Definition: Def.h:46
const std::string GOPXL_DISCOVERY_CONTROL_PORT
Definition: GoDiscoveryClient.h:34
const kSSize CLIENT_SOCKET_SIZE
Definition: GoDiscoveryClient.h:27
k64u length
Definition: GoDiscoveryClient.h:47