Class: Websocket::Echo::Io::Handler
- Inherits:
-
Object
- Object
- Websocket::Echo::Io::Handler
- Defined in:
- lib/websocket/echo/io/handler.rb
Constant Summary collapse
- GOODBYE_LINE =
"See you in a bit."
- SHUTDOWN_LINE =
"Server going away\r\n"
Instance Method Summary collapse
Instance Method Details
#on_message(client, data) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/websocket/echo/io/handler.rb', line 17 def (client, data) client.write data return unless /^Goodbye\b/.match?(data) client.write GOODBYE_LINE client.close end |
#on_open(client) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/websocket/echo/io/handler.rb', line 10 def on_open(client) # Set a connection timeout client.timeout = 10 # Write a welcome message client.write "WebSocket-Echo-IO server powered by Iodine #{Iodine::VERSION}.\r\n" end |
#on_shutdown(client) ⇒ Object
26 27 28 |
# File 'lib/websocket/echo/io/handler.rb', line 26 def on_shutdown(client) client.write SHUTDOWN_LINE end |