Skip to content

Commit 6eee057

Browse files
Close #38
1 parent 719c155 commit 6eee057

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

libs/ofxLibwebsockets/include/ofxLibwebsockets/Client.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ namespace ofxLibwebsockets {
2020
string channel;
2121
string protocol;
2222
int version;
23+
24+
// advanced: timeout options
25+
// names are from libwebsockets (ka == keep alive)
26+
int ka_time; // 0 == default, no timeout; nonzero == time to wait in seconds before testing conn
27+
int ka_probes; // # of times to test for connection; ignored if ka_time == 0
28+
int ka_interval; // how long to wait between probes, in seconds; ignored if ka_time == 0
2329
};
2430

2531
// call this function to set up a vanilla client options object
@@ -31,6 +37,10 @@ namespace ofxLibwebsockets {
3137
opts.channel = "/";
3238
opts.protocol = "NULL";
3339
opts.version = -1; //use latest version
40+
41+
opts.ka_time = 0;
42+
opts.ka_probes = 0;
43+
opts.ka_interval = 0;
3444
return opts;
3545
};
3646

libs/ofxLibwebsockets/include/ofxLibwebsockets/Server.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,25 @@ namespace ofxLibwebsockets {
3333
string sslKeyPath; // data path to ssl key
3434

3535
string documentRoot; // where your hosted files are (libwebsockets sets up a minimal webserver)
36+
37+
// advanced: timeout options
38+
// names are from libwebsockets (ka == keep alive)
39+
int ka_time; // 0 == default, no timeout; nonzero == time to wait in seconds before testing conn
40+
int ka_probes; // # of times to test for connection; ignored if ka_time == 0
41+
int ka_interval; // how long to wait between probes, in seconds; ignored if ka_time == 0
3642
};
3743

3844
static ServerOptions defaultServerOptions(){
3945
ServerOptions opts;
40-
opts.port = 80;
41-
opts.protocol = "NULL";
42-
opts.bUseSSL = false;
43-
opts.sslCertPath = ofToDataPath("ssl/libwebsockets-test-server.pem", true);
44-
opts.sslKeyPath = ofToDataPath("ssl/libwebsockets-test-server.key.pem", true);
45-
opts.documentRoot = ofToDataPath("web", true);
46+
opts.port = 80;
47+
opts.protocol = "NULL"; // NULL == no protocol. most websockets behave this way.
48+
opts.bUseSSL = false;
49+
opts.sslCertPath = ofToDataPath("ssl/libwebsockets-test-server.pem", true);
50+
opts.sslKeyPath = ofToDataPath("ssl/libwebsockets-test-server.key.pem", true);
51+
opts.documentRoot = ofToDataPath("web", true);
52+
opts.ka_time = 0;
53+
opts.ka_probes = 0;
54+
opts.ka_interval = 0;
4655
return opts;
4756
}
4857

@@ -53,7 +62,11 @@ namespace ofxLibwebsockets {
5362
Server();
5463
~Server();
5564

65+
// setup with default options for websockets
5666
bool setup( int _port = 80, bool bUseSSL = false );
67+
68+
// pass in ServerOptions object, which are easily instantiated
69+
// with ofxLibwebsockets::defaultServerOptions()
5770
bool setup( ServerOptions options );
5871

5972
// close the server

0 commit comments

Comments
 (0)