(ws) ws echo_server gains a new option (-p) to disable responding to pings with pongs
This commit is contained in:
		@@ -4,6 +4,7 @@ All changes to this project will be documented in this file.
 | 
				
			|||||||
## [8.2.7] - 2020-03-17
 | 
					## [8.2.7] - 2020-03-17
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(ws) ws connect gains a new option to set the interval at which to send pings
 | 
					(ws) ws connect gains a new option to set the interval at which to send pings
 | 
				
			||||||
 | 
					(ws) ws echo_server gains a new option (-p) to disable responding to pings with pongs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
IXWebSocket$ ws connect --ping_interval 2 wss://echo.websocket.org
 | 
					IXWebSocket$ ws connect --ping_interval 2 wss://echo.websocket.org
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,4 +6,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define IX_WEBSOCKET_VERSION "8.2.6"
 | 
					#define IX_WEBSOCKET_VERSION "8.2.7"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -187,6 +187,7 @@ int main(int argc, char** argv)
 | 
				
			|||||||
    echoServerApp->add_flag("-g", greetings, "Verbose");
 | 
					    echoServerApp->add_flag("-g", greetings, "Verbose");
 | 
				
			||||||
    echoServerApp->add_flag("-6", ipv6, "IpV6");
 | 
					    echoServerApp->add_flag("-6", ipv6, "IpV6");
 | 
				
			||||||
    echoServerApp->add_flag("-x", disablePerMessageDeflate, "Disable per message deflate");
 | 
					    echoServerApp->add_flag("-x", disablePerMessageDeflate, "Disable per message deflate");
 | 
				
			||||||
 | 
					    echoServerApp->add_flag("-p", disablePong, "Disable sending PONG in response to PING");
 | 
				
			||||||
    addTLSOptions(echoServerApp);
 | 
					    addTLSOptions(echoServerApp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server");
 | 
					    CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server");
 | 
				
			||||||
@@ -403,7 +404,7 @@ int main(int argc, char** argv)
 | 
				
			|||||||
    else if (app.got_subcommand("echo_server"))
 | 
					    else if (app.got_subcommand("echo_server"))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ret = ix::ws_echo_server_main(
 | 
					        ret = ix::ws_echo_server_main(
 | 
				
			||||||
            port, greetings, hostname, tlsOptions, ipv6, disablePerMessageDeflate);
 | 
					            port, greetings, hostname, tlsOptions, ipv6, disablePerMessageDeflate, disablePong);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (app.got_subcommand("broadcast_server"))
 | 
					    else if (app.got_subcommand("broadcast_server"))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								ws/ws.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								ws/ws.h
									
									
									
									
									
								
							@@ -32,7 +32,8 @@ namespace ix
 | 
				
			|||||||
                            const std::string& hostname,
 | 
					                            const std::string& hostname,
 | 
				
			||||||
                            const ix::SocketTLSOptions& tlsOptions,
 | 
					                            const ix::SocketTLSOptions& tlsOptions,
 | 
				
			||||||
                            bool ipv6,
 | 
					                            bool ipv6,
 | 
				
			||||||
                            bool disablePerMessageDeflate);
 | 
					                            bool disablePerMessageDeflate,
 | 
				
			||||||
 | 
					                            bool disablePong);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int ws_broadcast_server_main(int port,
 | 
					    int ws_broadcast_server_main(int port,
 | 
				
			||||||
                                 const std::string& hostname,
 | 
					                                 const std::string& hostname,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,8 @@ namespace ix
 | 
				
			|||||||
                            const std::string& hostname,
 | 
					                            const std::string& hostname,
 | 
				
			||||||
                            const ix::SocketTLSOptions& tlsOptions,
 | 
					                            const ix::SocketTLSOptions& tlsOptions,
 | 
				
			||||||
                            bool ipv6,
 | 
					                            bool ipv6,
 | 
				
			||||||
                            bool disablePerMessageDeflate)
 | 
					                            bool disablePerMessageDeflate,
 | 
				
			||||||
 | 
					                            bool disablePong)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        spdlog::info("Listening on {}:{}", hostname, port);
 | 
					        spdlog::info("Listening on {}:{}", hostname, port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,6 +36,12 @@ namespace ix
 | 
				
			|||||||
            server.disablePerMessageDeflate();
 | 
					            server.disablePerMessageDeflate();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (disablePong)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            spdlog::info("Disable responding to PING messages with PONG");
 | 
				
			||||||
 | 
					            server.disablePong();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        server.setOnConnectionCallback(
 | 
					        server.setOnConnectionCallback(
 | 
				
			||||||
            [greetings](std::shared_ptr<ix::WebSocket> webSocket,
 | 
					            [greetings](std::shared_ptr<ix::WebSocket> webSocket,
 | 
				
			||||||
                        std::shared_ptr<ConnectionState> connectionState) {
 | 
					                        std::shared_ptr<ConnectionState> connectionState) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user