Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
SocketIO
CEmscriptenWebsocket.h
1
#pragma once
2
#include "IWebsocket.h"
3
4
#ifdef __EMSCRIPTEN__
5
6
#include <vector>
7
#include <string>
8
#include <functional>
9
#include <emscripten/emscripten.h>
10
#include <emscripten/websocket.h>
11
12
namespace
Skylicht
13
{
14
namespace
Network
15
{
16
class
CEmscriptenWebsocket :
public
IWebsocket
17
{
18
public
:
19
CEmscriptenWebsocket();
20
virtual
~CEmscriptenWebsocket();
21
22
// IWebsocket
23
virtual
bool
connect(
const
std::string& url,
const
std::string& origin);
24
virtual
void
send(
const
std::string& message);
25
virtual
void
poll(
int
timeout = 0);
26
virtual
void
dispatch(std::function<
void
(
const
std::string&)> callable);
27
virtual
bool
isClosed();
28
29
private
:
30
static
EM_BOOL onOpen(
int
,
const
EmscriptenWebSocketOpenEvent* e,
void
* userData);
31
static
EM_BOOL onError(
int
,
const
EmscriptenWebSocketErrorEvent* e,
void
* userData);
32
static
EM_BOOL onClose(
int
,
const
EmscriptenWebSocketCloseEvent* e,
void
* userData);
33
static
EM_BOOL onMessage(
int
,
const
EmscriptenWebSocketMessageEvent* e,
void
* userData);
34
35
private
:
36
EMSCRIPTEN_WEBSOCKET_T m_ws;
37
bool
m_open;
38
bool
m_closed;
39
std::vector<std::string> m_messages;
40
};
41
}
42
}
43
44
#endif
// __EMSCRIPTEN__
Skylicht::Network::IWebsocket
Definition
IWebsocket.h:13
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
Generated by
1.17.0