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