39#ifndef _WebSocketServer_h
40#define _WebSocketServer_h
86 struct WSSCB* o,
struct WSS* wss,
void* data,
int len,
int text);
132#define WSSCB_constructor(o, frame, close, ping) \
133 (o)->frameFp=frame,(o)->closeFp=close,(o)->pingFp=ping
138 WSSCB_constructor(
this, frameFp, closeFp, pingFp);
189 int write(
const void* data,
int len,
bool isTxt);
196 int close(
int statusCode=1000);
213BA_API
void WSS_constructor(
215BA_API
void WSS_destructor(
WSS* o);
218BA_API
int WSS_rawWrite(
WSS* o,
const void* data,
int len,
int opCode);
219#define WSS_write(o, data, len, isTxt) WSS_rawWrite(o, data, len, isTxt?1:2)
220BA_API
int WSS_close(
WSS* o,
int statusCode);
221#define WSS_isValid(o) SoDispCon_isValid((SoDispCon*)o)
226 WSS_constructor(
this, cb, disp, startSize, expandSize);
229 WSS_destructor(
this);
232 return WSS_upgrade(
this, req);
235 return WSS_connect(
this, con);
237inline int WSS::write(
const void* data,
int len,
bool isTxt) {
238 return WSS_write(
this, data, len,isTxt);
241 return WSS_close(
this, statusCode);
244 return WSS_isValid(
this) ? true :
false; }
struct WSSCB WSSCB
WebSocket Server Connection Callback Interface: provides an interface between your application and th...
WSSCB(WSSCB_Frame frameFp, WSSCB_Close closeFp, WSSCB_Ping pingFp=0)
Provide your callback event functions.
Definition: WebSocketServer.h:136
bool isValid()
Returns true if the WebSocket connection is valid.
Definition: WebSocketServer.h:243
int close(int statusCode=1000)
Gracefully close the WebSocket connection by sending WebSocket status code N to the client prior to c...
Definition: WebSocketServer.h:240
~WSS()
destructor.
Definition: WebSocketServer.h:228
int write(const void *data, int len, bool isTxt)
Write/send a WebSocket frame.
Definition: WebSocketServer.h:237
struct WSS WSS
WebSocket Server (WSS)
void(* WSSCB_Ping)(struct WSSCB *o, struct WSS *wss, void *data, int len)
Optional webSocket callback: the function is called when the client sends a ping message.
Definition: WebSocketServer.h:96
void(* WSSCB_Frame)(struct WSSCB *o, struct WSS *wss, void *data, int len, int text)
WebSocket callback: a WebSocket frame is received.
Definition: WebSocketServer.h:85
WSS(WSSCB *cb, SoDisp *disp, int startSize, int expandSize)
Create and initialize a WebSocket Server instance.
Definition: WebSocketServer.h:225
void(* WSSCB_Close)(struct WSSCB *o, struct WSS *wss, int status)
WebSocket callback: the client closed the connection or the connection closed unexpectedly.
Definition: WebSocketServer.h:109
int connect(HttpConnection *con)
Upgrades (morphs) an HTTP request to a persistent WebSocket connection.
Definition: WebSocketServer.h:234
int upgrade(HttpRequest *req)
Upgrades an HTTP server request to a persistent WebSocket connection.
Definition: WebSocketServer.h:231
A dynamic buffer.
Definition: DynBuffer.h:60
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86
WebSocket Server Connection Callback Interface: provides an interface between your application and th...
Definition: WebSocketServer.h:117
WebSocket Server (WSS)
Definition: WebSocketServer.h:146