libASPL
Loading...
Searching...
No Matches
Client.hpp
Go to the documentation of this file.
1// Copyright (c) libASPL authors
2// Licensed under MIT
3
4//! @file aspl/Client.hpp
5//! @brief Client.
6
7#pragma once
8
9#include <CoreFoundation/CoreFoundation.h>
10
11#include <string>
12
13#include <unistd.h>
14
15namespace aspl {
16
17//! Information about client.
19{
20 //! Client identifier.
21 //! Allows for differentiating multiple clients in the same process.
22 UInt32 ClientID = 0;
23
24 //! Client PID.
25 //! The pid_t of the process that contains the client.
26 pid_t ProcessID = 0;
27
28 //! Client endianness.
29 //! Indicating whether or not the client has the same endianness as the server.
30 bool IsNativeEndian = false;
31
32 //! Client bundle.
33 //! Bundle ID of the main bundle of the process that contains the client.
34 std::string BundleID = "";
35};
36
37//! Device client.
38//!
39//! Represents connection between an app and device. Typically an app has at most
40//! one client, but this is not a requirement.
41//!
42//! Devices asks RequestHandler to create Client object when a new client comes
43//! to the devices, and asks to remove it when the client leaves.
44//!
45//! You may subclass Client if you need to keep additional per-client state. To
46//! incorporate your own client class, you'll need to set custom RequestHandler.
47class Client
48{
49public:
50 //! Construct client from ClientInfo.
51 Client(const ClientInfo& clientInfo);
52
53 Client(const Client&) = delete;
54 Client& operator=(const Client&) = delete;
55
56 virtual ~Client() = default;
57
58 //! Client identifier.
59 //! Allows for differentiating multiple clients in the same process.
60 UInt32 GetClientID() const;
61
62 //! Client PID.
63 //! The pid_t of the process that contains the client.
64 pid_t GetProcessID() const;
65
66 //! Client endianness.
67 //! Indicating whether or not the client has the same endianness as the server.
68 bool GetIsNativeEndian() const;
69
70 //! Client bundle.
71 //! Bundle ID of the main bundle of the process that contains the client.
72 std::string GetBundleID() const;
73
74private:
75 const ClientInfo info_;
76};
77
78} // namespace aspl
Device client.
Definition Client.hpp:48
UInt32 GetClientID() const
Client identifier. Allows for differentiating multiple clients in the same process.
Client(const ClientInfo &clientInfo)
Construct client from ClientInfo.
std::string GetBundleID() const
Client bundle. Bundle ID of the main bundle of the process that contains the client.
pid_t GetProcessID() const
Client PID. The pid_t of the process that contains the client.
bool GetIsNativeEndian() const
Client endianness. Indicating whether or not the client has the same endianness as the server.
Information about client.
Definition Client.hpp:19
UInt32 ClientID
Client identifier. Allows for differentiating multiple clients in the same process.
Definition Client.hpp:22
pid_t ProcessID
Client PID. The pid_t of the process that contains the client.
Definition Client.hpp:26
bool IsNativeEndian
Client endianness. Indicating whether or not the client has the same endianness as the server.
Definition Client.hpp:30
std::string BundleID
Client bundle. Bundle ID of the main bundle of the process that contains the client.
Definition Client.hpp:34