minor refactoring
This commit is contained in:
		| @@ -203,7 +203,11 @@ namespace ix | ||||
|             WebSocketOpenInfo(status.uri, status.headers, status.protocol), | ||||
|             WebSocketCloseInfo())); | ||||
|  | ||||
|         if (_pingIntervalSecs > 0) | ||||
|         { | ||||
|             // Send a heart beat right away | ||||
|             _ws.sendHeartBeat(); | ||||
|         } | ||||
|  | ||||
|         return status; | ||||
|     } | ||||
| @@ -232,7 +236,11 @@ namespace ix | ||||
|                                                WebSocketOpenInfo(status.uri, status.headers), | ||||
|                                                WebSocketCloseInfo())); | ||||
|  | ||||
|         if (_pingIntervalSecs > 0) | ||||
|         { | ||||
|             // Send a heart beat right away | ||||
|             _ws.sendHeartBeat(); | ||||
|         } | ||||
|  | ||||
|         return status; | ||||
|     } | ||||
|   | ||||
| @@ -215,14 +215,12 @@ namespace ix | ||||
|         return now - _lastSendPingTimePoint > std::chrono::seconds(_pingIntervalSecs); | ||||
|     } | ||||
|  | ||||
|     void WebSocketTransport::sendHeartBeat() | ||||
|     WebSocketSendInfo WebSocketTransport::sendHeartBeat() | ||||
|     { | ||||
|         if (_pingIntervalSecs <= 0) return; | ||||
|  | ||||
|         _pongReceived = false; | ||||
|         std::stringstream ss; | ||||
|         ss << kPingMessage << "::" << _pingIntervalSecs << "s"; | ||||
|         sendPing(ss.str()); | ||||
|         return sendPing(ss.str()); | ||||
|     } | ||||
|  | ||||
|     bool WebSocketTransport::closingDelayExceeded() | ||||
|   | ||||
| @@ -105,7 +105,8 @@ namespace ix | ||||
|         void dispatch(PollResult pollResult, const OnMessageCallback& onMessageCallback); | ||||
|         size_t bufferedAmount() const; | ||||
|  | ||||
|         void sendHeartBeat(); | ||||
|         // internal | ||||
|         WebSocketSendInfo sendHeartBeat(); | ||||
|  | ||||
|     private: | ||||
|         std::string _url; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user