-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
57 lines (40 loc) · 1.66 KB
/
README
File metadata and controls
57 lines (40 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
WebSocket Server using WinSock
Fully Functional WebSocket Server
TODO:
- Add support for WebSocket V13 frames.
Compiling:
Compiled with VS2010 on Windows and G++ 4.6.3 on Ubuntu & Mac OSX Lion
Linux Variants:
Open a CLI in the working directory and run make then launch the Server by executing
./WebSocket
Windows:
Compile with VS2008+
API Usage:
So far I have just implemented simple callbacks as such:
ON_OPEN: When the client connects to the websocket server before its handshaken.
ON_CLOSE: When the client has disconnected from the server
ON_RECV: When the client has sent data
There are two forms of callback types blocking and non blocking pretty self explanatory:
ON_OPEN_BLOCKING: Blocks ON_OPEN
ON_CLOSE_BLOCKING: Blocks ON_CLOSE
ON_RECV_BLOCKING: Blocks RECV
Example:
void foo(void* param);
void bar(void* param);
void foobar(void* param);
WebSocket::WServer *server = new WebSocket::WServer(8181);
server->registerCallback(WebSocket::ON_OPEN,foo);
server->registerCallback(WebSocket::ON_CLOSE_BLOCKING,bar);
server->registerCallback(WebSocket::ON_RECV_BLOCKING,foobar);
server->Listen();
Format for creating API Methods:
As of current there is only one implementation where the void star paramater matters and thats ON_RECV & ON_RECV_BLOCKING. If you implement a function with RECV it will pass the data received as the void pointer.
Example:
void foo(void* param)
{
char* data = (char*)param;
std::cout << "Data: " << data << std::endl;
}
server->registerCallback(WebSocket::ON_RECV,foo);
General Method Format:
void METHODNAME(void* PARAMNAME);