NAP
nap
system_modules
napapiwebsocket
src
apiwebsocketclient.h
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5
#pragma once
6
7
// External Includes
8
#include <apievent.h>
9
#include <websocketclient.h>
10
11
namespace
nap
12
{
13
// Forward Declares
14
class
APIWebSocketService;
15
class
APIService;
16
59
class
NAPAPI
APIWebSocketClient
:
public
IWebSocketClient
60
{
61
RTTI_ENABLE(
IWebSocketClient
)
62
public
:
67
APIWebSocketClient
(
APIWebSocketService
& service);
68
91
bool
send(
APIEventPtr
apiEvent,
utility::ErrorState
& error);
92
93
bool
mSendWebSocketEvents =
true
;
94
bool
mVerbose =
true
;
95
96
protected
:
97
98
// Called by web-socket client endpoint when the connection is opened
99
virtual
void
onConnectionOpened()
override
;
100
101
// Called by web-socket client endpoint when the connection is closed
102
virtual
void
onConnectionClosed(
int
code,
const
std::string& reason)
override
;
103
104
// Called by web-socket client endpoint when the connection failed to establish
105
virtual
void
onConnectionFailed(
int
code,
const
std::string& reason)
override
;
106
107
// Called by web-socket client endpoint when a new message is received
108
virtual
void
onMessageReceived(
const
WebSocketMessage
& message)
override
;
109
110
private
:
111
112
APIService
* mAPIService =
nullptr
;
113
};
114
115
// Object creator used for constructing the api web-socket client
116
using
APIWebSocketClientObjectCreator
=
rtti::ObjectCreator<APIWebSocketClient, APIWebSocketService>
;
117
}
nap::APIWebSocketClient
Definition:
apiwebsocketclient.h:59
nap::rtti::ObjectCreator
Definition:
factory.h:49
nap::utility::ErrorState
Definition:
errorstate.h:19
nap::APIService
Definition:
apiservice.h:47
nap::WebSocketMessage
Definition:
websocketmessage.h:29
nap::APIEventPtr
std::unique_ptr< nap::APIEvent > APIEventPtr
Definition:
apievent.h:179
nap::IWebSocketClient
Definition:
websocketclient.h:34
nap
Definition:
templateapp.h:17
nap::APIWebSocketService
Definition:
apiwebsocketservice.h:18
Generated by doxygen