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