File tree Expand file tree Collapse file tree 4 files changed +12
-6
lines changed
Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ namespace ofxLibwebsockets {
1616
1717 class Event {
1818 public:
19- Event (Connection& _conn, std::string& _message, bool isBinary=false );
19+ Event (Connection& _conn, std::string _message, bool isBinary=false );
2020
2121 Connection& conn;
22- std::string& message; // message from ws OR error message if error
22+ std::string message; // message from ws OR error message if error
2323 Json::Value json;
2424
2525 // binary data
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ namespace ofxLibwebsockets {
3131 Connection::~Connection (){
3232 free (buf);
3333 free (binaryBuf);
34+
35+ // delete all pending frames
36+ messages_binary.clear ();
37+ messages_text.clear ();
3438 }
3539 // --------------------------------------------------------------
3640 void Connection::close () {
@@ -194,8 +198,10 @@ namespace ofxLibwebsockets {
194198 void Connection::setIdle ( bool isIdle ){
195199 idle = isIdle;
196200 static string dum =" " ;
197- Event args (*this , dum);
198- ofNotifyEvent (protocol->onidleEvent , args);
201+ if ( protocol != NULL ){
202+ Event args (*this , dum);
203+ ofNotifyEvent (protocol->onidleEvent , args);
204+ }
199205 }
200206
201207 // --------------------------------------------------------------
Original file line number Diff line number Diff line change 1010namespace ofxLibwebsockets {
1111
1212 // --------------------------------------------------------------
13- Event::Event (Connection& _conn, std::string& _message, bool isBinary)
13+ Event::Event (Connection& _conn, std::string _message, bool isBinary)
1414 : conn(_conn)
1515 , message(_message)
1616 , isBinary(isBinary)
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ namespace ofxLibwebsockets {
105105
106106 // this happens with events that don't use the connection
107107 // so not always a problem
108- if (conn == NULL || conn->protocol == NULL ){
108+ if (conn == NULL || conn->protocol == NULL || conn-> ws == NULL ){
109109 if (conn == NULL ){
110110 ofLog (OF_LOG_WARNING, " [ofxLibwebsockets] connection is null " );
111111 } else {
You can’t perform that action at this time.
0 commit comments