API Documentation
Loading...
Searching...
No Matches
SocketIOChannel.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Hardware
28File: SocketIOChannel
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "Base/Headers/String.h"
34#include "Base/Headers/UUID.h"
35
36namespace NDEVR
37{
39 {
40 friend class SocketIO;
41 protected:
45 , m_name(name)
46 {
47 lib_assert(name.size() > 0 && !name.contains('|'), "Bad Socket channel name");
48 }
49 SocketIOChannel(const String& name, std::function<void(const char* data, uint04 size)> data_callback, UUID target = Constant<UUID>::NaN)
50 : m_recieve_data_callback(data_callback)
52 , m_name(name)
53 {
54 lib_assert(name.size() > 0 && !name.contains('|'), "Bad Socket channel name");
55 }
56 public:
57 void setRecieveDataCallback(std::function<void(const char* data, uint04 size)> data_callback) { m_recieve_data_callback = data_callback; };
58 void sendData(const char* data, uint04 size)
59 {
60 lib_assert(m_send_data_callback, "Tried to send without socket IO connection");
62 m_send_data_callback(data, size);
63 };
64 const String& name() const { return m_name; }
65 const UUID& target() const { return m_target; }
66 protected:
67 void setSendDataCallback(std::function<void(const char* data, uint04 size)> data_callback) { m_send_data_callback = data_callback; };
68 void recieveData(const char* data, uint04 size)
69 {
71 m_recieve_data_callback(data, size);
72 };
73 protected:
74 std::function<void(const char* data, uint04 size)> m_recieve_data_callback;
75 std::function<void(const char* data, uint04 size)> m_send_data_callback;
78 };
79}
80
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
bool contains(const t_type &element) const
Definition Buffer.hpp:674
constexpr t_index_type size() const
Definition Buffer.hpp:1461
Definition SocketIOChannel.h:39
void recieveData(const char *data, uint04 size)
Definition SocketIOChannel.h:68
void setRecieveDataCallback(std::function< void(const char *data, uint04 size)> data_callback)
Definition SocketIOChannel.h:57
SocketIOChannel(const String &name, std::function< void(const char *data, uint04 size)> data_callback, UUID target=Constant< UUID >::NaN)
Definition SocketIOChannel.h:49
std::function< void(const char *data, uint04 size)> m_recieve_data_callback
Definition SocketIOChannel.h:74
UUID m_target
Definition SocketIOChannel.h:76
SocketIOChannel(const String &name, UUID target=Constant< UUID >::NaN)
Definition SocketIOChannel.h:42
const UUID & target() const
Definition SocketIOChannel.h:65
const String & name() const
Definition SocketIOChannel.h:64
String m_name
Definition SocketIOChannel.h:77
std::function< void(const char *data, uint04 size)> m_send_data_callback
Definition SocketIOChannel.h:75
void setSendDataCallback(std::function< void(const char *data, uint04 size)> data_callback)
Definition SocketIOChannel.h:67
void sendData(const char *data, uint04 size)
Definition SocketIOChannel.h:58
friend class SocketIO
Definition SocketIOChannel.h:40
Definition String.h:40
Definition UUID.h:66
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
Definition BaseValues.hpp:272