File size: 3,023 Bytes
053b80b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __SESSIONCLIENT_H__
#define __SESSIONCLIENT_H__

#include <string>
#include <future>
#include <functional>
#include <exception>

#include "messages/Frame.pb.h"
#include "messages/Session.pb.h"

#include "common/Frame.h"
#include "client/IRouterClient.h"
#include "client/NotificationHandler.h"

#if __cplusplus >= 201402L
#define DEPRECATED [[ deprecated ]]
#define DEPRECATED_MSG(msg) [[ deprecated(msg) ]]
#elif defined(__GNUC__)
#define DEPRECATED __attribute__ ((deprecated))
#define DEPRECATED_MSG(msg) __attribute__ ((deprecated(msg)))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#define DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#else
#define DEPRECATED 
#define DEPRECATED_MSG 
#endif
namespace Kinova
{
namespace Api
{
	namespace Session
	{
		// todogr move somewhere else
		const std::string   none = "";
		
		enum FunctionUids

		{
			eUidCreateSession = 0x10001,
			eUidCloseSession = 0x10002,
			eUidKeepAlive = 0x10003,
			eUidGetConnections = 0x10004,
		};
		
		class SessionClient

		{
			static const uint32_t m_serviceVersion = 1;
			static const uint32_t m_serviceId = eIdSession;
			NotificationHandler m_notificationHandler;

		protected:
			IRouterClient* const m_clientRouter;

		public:
			SessionClient(IRouterClient* clientRouter);
			static uint32_t getUniqueFctId(uint16_t fctId);

			void CreateSession(const CreateSessionInfo& createsessioninfo, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void CreateSession_callback(const CreateSessionInfo& createsessioninfo, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> CreateSession_async(const CreateSessionInfo& createsessioninfo, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void CloseSession(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void CloseSession_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> CloseSession_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void KeepAlive(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void KeepAlive_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> KeepAlive_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			ConnectionList GetConnections(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void GetConnections_callback(std::function< void (const Error&, const ConnectionList&) > callback, uint32_t deviceId = 0);
			std::future<ConnectionList> GetConnections_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});


		private:
			void messageHeaderValidation(const Frame& msgFrame){ /* todogr ... */ }
		};
	}
}
}

#endif