File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ namespace ofxLibwebsockets {
5151 // force close this client
5252 void close ();
5353
54+ // check if connected
55+ bool isConnected ();
56+
5457 // most basic send function
5558 void send ( string message );
5659
Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ namespace ofxLibwebsockets {
127127 ofLogError () << " [ofxLibwebsockets] client connection failed" ;
128128 return false ;
129129 } else {
130-
131130 connection = new Connection ( (Reactor*) &context, &clientProtocol );
132131 connection->ws = lwsconnection;
133132
@@ -137,6 +136,18 @@ namespace ofxLibwebsockets {
137136 }
138137 }
139138 }
139+
140+ // --------------------------------------------------------------
141+ bool Client::isConnected (){
142+ if ( connection == NULL || lwsconnection == NULL ){
143+ return false ;
144+ } else {
145+ // we need a better boolean switch...
146+ // for now, connections vector is only populated
147+ // with valid connections
148+ return connections.size () > 0 ;
149+ }
150+ }
140151
141152 // --------------------------------------------------------------
142153 void Client::close (){
You can’t perform that action at this time.
0 commit comments