Ping timeout use constant (#36)
* use constant for ping timeout * change close code types
This commit is contained in:
		
				
					committed by
					
						
						Benjamin Sergeant
					
				
			
			
				
	
			
			
			
						parent
						
							f61fd7b7f1
						
					
				
				
					commit
					aea859af52
				
			@@ -69,10 +69,11 @@ namespace ix
 | 
				
			|||||||
    const int WebSocketTransport::kDefaultPingTimeoutSecs(-1);
 | 
					    const int WebSocketTransport::kDefaultPingTimeoutSecs(-1);
 | 
				
			||||||
    const bool WebSocketTransport::kDefaultEnablePong(true);
 | 
					    const bool WebSocketTransport::kDefaultEnablePong(true);
 | 
				
			||||||
    constexpr size_t WebSocketTransport::kChunkSize;
 | 
					    constexpr size_t WebSocketTransport::kChunkSize;
 | 
				
			||||||
    const int WebSocketTransport::kInternalErrorCode(1011);
 | 
					    const uint16_t WebSocketTransport::kInternalErrorCode(1011);
 | 
				
			||||||
    const int WebSocketTransport::kAbnormalCloseCode(1006);
 | 
					    const uint16_t WebSocketTransport::kAbnormalCloseCode(1006);
 | 
				
			||||||
    const std::string WebSocketTransport::kInternalErrorMessage("Internal error");
 | 
					    const std::string WebSocketTransport::kInternalErrorMessage("Internal error");
 | 
				
			||||||
    const std::string WebSocketTransport::kAbnormalCloseMessage("Abnormal closure");
 | 
					    const std::string WebSocketTransport::kAbnormalCloseMessage("Abnormal closure");
 | 
				
			||||||
 | 
					    const std::string WebSocketTransport::kPingTimeoutMessage("Ping timeout");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebSocketTransport::WebSocketTransport() :
 | 
					    WebSocketTransport::WebSocketTransport() :
 | 
				
			||||||
        _useMask(true),
 | 
					        _useMask(true),
 | 
				
			||||||
@@ -240,7 +241,7 @@ namespace ix
 | 
				
			|||||||
                    // exceeds the maximum delay, then close the connection
 | 
					                    // exceeds the maximum delay, then close the connection
 | 
				
			||||||
                    if (pingTimeoutExceeded())
 | 
					                    if (pingTimeoutExceeded())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        close(1011, "Ping timeout");
 | 
					                        close(kInternalErrorCode, kPingTimeoutMessage);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    // If (1) ping is enabled and no ping has been sent for a duration 
 | 
					                    // If (1) ping is enabled and no ping has been sent for a duration 
 | 
				
			||||||
                    // exceeding our ping interval, send a ping to the server.
 | 
					                    // exceeding our ping interval, send a ping to the server.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -160,10 +160,11 @@ namespace ix
 | 
				
			|||||||
        std::atomic<bool> _requestInitCancellation;
 | 
					        std::atomic<bool> _requestInitCancellation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Constants for dealing with closing conneections
 | 
					        // Constants for dealing with closing conneections
 | 
				
			||||||
        static const int kInternalErrorCode;
 | 
					        static const uint16_t kInternalErrorCode;
 | 
				
			||||||
        static const int kAbnormalCloseCode;
 | 
					        static const uint16_t kAbnormalCloseCode;
 | 
				
			||||||
        const static std::string kInternalErrorMessage;
 | 
					        const static std::string kInternalErrorMessage;
 | 
				
			||||||
        const static std::string kAbnormalCloseMessage;
 | 
					        const static std::string kAbnormalCloseMessage;
 | 
				
			||||||
 | 
					        const static std::string kPingTimeoutMessage;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
        // enable auto response to ping
 | 
					        // enable auto response to ping
 | 
				
			||||||
        bool _enablePong;
 | 
					        bool _enablePong;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user