Skip to content

Commit 719c155

Browse files
Added isConnected to client
1 parent 4edb948 commit 719c155

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

libs/ofxLibwebsockets/include/ofxLibwebsockets/Client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

libs/ofxLibwebsockets/src/Client.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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(){

0 commit comments

Comments
 (0)