Skip to content

Commit cb92ac1

Browse files
committed
Resolves connection close problem if it is not connected.
1 parent c1998ae commit cb92ac1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

websocket-rails-client/websocket_rails.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::string WebsocketRails::connect() {
4343
this->conn = new WebsocketConnection(this->url, *this);
4444
this->websocket_connection_thread = boost::thread(&WebsocketConnection::run, this->conn);
4545
int count = 0;
46-
while(this->connectionStale()) {
46+
while(!this->isConnected()) {
4747
boost::posix_time::seconds workTime(1);
4848
boost::this_thread::sleep(workTime);
4949
count++;
@@ -57,7 +57,9 @@ std::string WebsocketRails::connect() {
5757

5858
std::string WebsocketRails::disconnect() {
5959
if(this->conn != 0) {
60-
this->conn->close();
60+
if(this->isConnected()) {
61+
this->conn->close();
62+
}
6163
this->websocket_connection_thread.join();
6264
delete this->conn;
6365
}

0 commit comments

Comments
 (0)