Sha256: a062216cb5ded0a2620fc1af2edb6910f3993d4e282c461746cdc69ad9b1da84
Contents?: true
Size: 578 Bytes
Versions: 1
Compression:
Stored size: 578 Bytes
Contents
# WebSocket echo server require 'rubygems' require 'rev/websocket' class EchoConnection < Rev::WebSocket def on_open puts "WebSocket opened from '#{peeraddr[2]}': request=#{request.inspect}" send_message("server: Hello, world!") end def on_message(data) puts "WebSocket data received: '#{data}'" send_message(data) end def on_close puts "WebSocket closed" end end host = '0.0.0.0' port = ARGV[0] || 8081 server = Rev::WebSocketServer.new(host, port, EchoConnection) server.attach(Rev::Loop.default) puts "start on #{host}:#{port}" Rev::Loop.default.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rev-websocket-0.1.3 | examples/echo.rb |