43 lines
1.8 KiB
C
43 lines
1.8 KiB
C
#ifndef WEBSOCKET_CONFIG_H
|
|
#define WEBSOCKET_CONFIG_H
|
|
|
|
#ifdef WITH_UWS
|
|
// uWebSockets implementation
|
|
// disable compression to avoid zlib dependency
|
|
// #define UWS_NO_ZLIB
|
|
#include "uws_websocket_bridge.h"
|
|
#include "uws_websocket_v8_bindings.h"
|
|
|
|
#define WEBSOCKET_BRIDGE_PREFIX "uws_"
|
|
#define WEBSOCKET_LOG_PREFIX "[UWS]"
|
|
#define WEBSOCKET_BIND_V8(isolate, context) bind_uws_websocket_bridge(isolate, context)
|
|
#else
|
|
// native WebSocket implementation
|
|
#include "socket_bridge.h"
|
|
#include "socket_v8_bindings.h"
|
|
#include "websocket_bridge.h"
|
|
#include "websocket_v8_bindings.h"
|
|
|
|
#define WEBSOCKET_BRIDGE_PREFIX "Native_"
|
|
#define WEBSOCKET_LOG_PREFIX "[NATIVE]"
|
|
#define WEBSOCKET_BIND_V8(isolate, context) do { \
|
|
bind_socket_bridge(isolate, context); \
|
|
bind_websocket_bridge(isolate, context); \
|
|
} while(0)
|
|
#endif
|
|
|
|
#ifdef WITH_UWS
|
|
#define WEBSOCKET_SERVER_CREATE(host, port, maxConn) uws_websocket_server_create(host, port, maxConn)
|
|
#define WEBSOCKET_SERVER_DESTROY(id) uws_websocket_server_destroy(id)
|
|
#define WEBSOCKET_SERVER_SEND_TO_ALL(id, data) uws_websocket_server_send_to_all(id, data)
|
|
#define WEBSOCKET_SERVER_SEND_TO_CLIENT(id, clientId, data) uws_websocket_server_send_to_client(id, clientId, data)
|
|
#define WEBSOCKET_SERVER_TICK(id) uws_websocket_server_tick(id)
|
|
#else
|
|
#define WEBSOCKET_SERVER_CREATE(host, port, maxConn) runt_websocket_server_create(host, port, maxConn)
|
|
#define WEBSOCKET_SERVER_DESTROY(id) runt_websocket_server_destroy(id)
|
|
#define WEBSOCKET_SERVER_SEND_TO_ALL(id, data) runt_websocket_server_send_to_all(id, data)
|
|
#define WEBSOCKET_SERVER_SEND_TO_CLIENT(id, clientId, data) runt_websocket_server_send_to_client(id, clientId, data)
|
|
#define WEBSOCKET_SERVER_TICK(id) runt_websocket_server_tick(id)
|
|
#endif
|
|
|
|
#endif |