Skip to content

Commit a62d84d

Browse files
committed
fixed crash on lws_callback()
list of reactor was empty because of static modifier
1 parent 8674848 commit a62d84d

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

libs/ofxLibwebsockets/include/ofxLibwebsockets/Reactor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ namespace ofxLibwebsockets {
7878

7979
};
8080

81-
static vector<Reactor *> reactors;
81+
extern vector<Reactor *> reactors;
8282
};

libs/ofxLibwebsockets/include/ofxLibwebsockets/Server.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,7 @@ namespace ofxLibwebsockets {
4040
int ka_interval; // how long to wait between probes, in seconds; ignored if ka_time == 0
4141
};
4242

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

5745
class Server : public Reactor {
5846
friend class Protocol;
@@ -131,4 +119,4 @@ namespace ofxLibwebsockets {
131119
Protocol serverProtocol;
132120
void threadedFunction();
133121
};
134-
};
122+
};

libs/ofxLibwebsockets/src/Reactor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace ofxLibwebsockets {
1111

12+
vector<Reactor *> reactors = vector<Reactor *>();
13+
1214
//--------------------------------------------------------------
1315
Reactor::Reactor()
1416
: context(NULL), waitMillis(50){

libs/ofxLibwebsockets/src/Server.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313

1414
namespace ofxLibwebsockets {
1515

16+
ServerOptions defaultServerOptions(){
17+
ServerOptions opts;
18+
opts.port = 80;
19+
opts.protocol = "NULL"; // NULL == no protocol. most websockets behave this way.
20+
opts.bUseSSL = false;
21+
opts.sslCertPath = ofToDataPath("ssl/libwebsockets-test-server.pem", true);
22+
opts.sslKeyPath = ofToDataPath("ssl/libwebsockets-test-server.key.pem", true);
23+
opts.documentRoot = ofToDataPath("web", true);
24+
opts.ka_time = 0;
25+
opts.ka_probes = 0;
26+
opts.ka_interval = 0;
27+
return opts;
28+
}
29+
1630
//--------------------------------------------------------------
1731
Server::Server(){
1832
context = NULL;

0 commit comments

Comments
 (0)