module WebSocketPinger
Defined in:
web-socket-pinger.crConstant Summary
-
VERSION =
"1.0.0"
Class Method Summary
-
.start(socket, ping_interval = 10.seconds, ping_timeout = 20.seconds, ping_message : String | Nil = nil, close_code : Int32 | HTTP::WebSocket::CloseCode = :going_away, close_message = "closed by ping-pong system")
Starts sending PING messages to given socket every ping_interval (defaults to 10 seconds) with ping_message payload (empty by default).
Class Method Detail
def self.start(socket, ping_interval = 10.seconds, ping_timeout = 20.seconds, ping_message : String | Nil = nil, close_code : Int32 | HTTP::WebSocket::CloseCode = :going_away, close_message = "closed by ping-pong system")
#
Starts sending PING messages to given socket every ping_interval (defaults to 10 seconds) with ping_message payload (empty by default).
If client does not respond in ping_timeout (defaults to 20 seconds), closes connection with close_code (defaults to 1001 GOING AWAY) and close_message (defaults to "closed by ping-pong system").
my_handler = HTTP::WebSocketHandler.new do |socket, context|
WebSocketPinger.start(socket)
# ...rest of handler code
end