save timepoints after connect and not in contructor, adjusted tests (#72)
* save timepoints after connect and not in contructor, adjusted tests * move call into setReadyState * more time to detect client close in test
This commit is contained in:
		
				
					committed by
					
						
						Benjamin Sergeant
					
				
			
			
				
	
			
			
			
						parent
						
							be2aee3354
						
					
				
				
					commit
					27bf1684cb
				
			@@ -134,11 +134,6 @@ namespace ix
 | 
			
		||||
        {
 | 
			
		||||
            _pingIntervalOrTimeoutGCDSecs = pingIntervalSecs;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (_pingIntervalOrTimeoutGCDSecs > 0)
 | 
			
		||||
        {
 | 
			
		||||
            _nextGCDTimePoint = std::chrono::steady_clock::now() + std::chrono::seconds(_pingIntervalOrTimeoutGCDSecs);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Client
 | 
			
		||||
@@ -225,6 +220,10 @@ namespace ix
 | 
			
		||||
            _closeWireSize = 0;
 | 
			
		||||
            _closeRemote = false;
 | 
			
		||||
        }
 | 
			
		||||
        else if (readyState == ReadyState::OPEN)
 | 
			
		||||
        {
 | 
			
		||||
            initTimePointsAndGCDAfterConnect();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _readyState = readyState;
 | 
			
		||||
    }
 | 
			
		||||
@@ -234,6 +233,23 @@ namespace ix
 | 
			
		||||
        _onCloseCallback = onCloseCallback;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void WebSocketTransport::initTimePointsAndGCDAfterConnect()
 | 
			
		||||
    {
 | 
			
		||||
        {
 | 
			
		||||
            std::lock_guard<std::mutex> lock(_lastSendPingTimePointMutex);
 | 
			
		||||
            _lastSendPingTimePoint = std::chrono::steady_clock::now();
 | 
			
		||||
        } 
 | 
			
		||||
        {
 | 
			
		||||
            std::lock_guard<std::mutex> lock(_lastReceivePongTimePointMutex);
 | 
			
		||||
            _lastReceivePongTimePoint = std::chrono::steady_clock::now();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (_pingIntervalOrTimeoutGCDSecs > 0)
 | 
			
		||||
        {
 | 
			
		||||
            _nextGCDTimePoint = std::chrono::steady_clock::now() + std::chrono::seconds(_pingIntervalOrTimeoutGCDSecs);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Only consider send PING time points for that computation.
 | 
			
		||||
    bool WebSocketTransport::pingIntervalExceeded()
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user