Sha256: 6a3da7be9d5ed02583c9fba23418d1eb3bc214c03b5ba885aacc048410f900e1
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
require File.expand_path('../../lib/websocket-eventmachine-server', __FILE__) EM.epoll EM.run do trap("TERM") { stop } trap("INT") { stop } WebSocket::EventMachine::Server.start(:host => "0.0.0.0", :port => 9001) do |ws| ws.onopen do puts "Client connected" end ws.onmessage do |msg, type| puts "Received message: #{msg}" ws.send msg, :type => type end ws.onclose do puts "Client disconnected" end ws.onerror do |e| puts "Error: #{e}" end ws.onping do |msg| puts "Receied ping: #{msg}" end ws.onpong do |msg| puts "Received pong: #{msg}" end end puts "Server started at port 9001" def stop puts "Terminating WebSocket Server" EventMachine.stop end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
websocket-eventmachine-server-1.0.1 | examples/echo_server.rb |
websocket-eventmachine-server-1.0.0 | examples/echo_server.rb |