Sha256: 164460e9433a158651b800ae962abaa66a2f6b3e73d7e342bf762ddb56137031
Contents?: true
Size: 566 Bytes
Versions: 13
Compression:
Stored size: 566 Bytes
Contents
require File.expand_path('../../lib/em-websocket', __FILE__) EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => false) do |ws| timer = nil ws.onopen { puts "Ping supported: #{ws.pingable?}" timer = EM.add_periodic_timer(1) { p ["Sent ping", ws.ping('hello')] } } ws.onpong { |value| puts "Received pong: #{value}" } ws.onping { |value| puts "Received ping: #{value}" } ws.onclose { EM.cancel_timer(timer) puts "WebSocket closed" } ws.onerror { |e| puts "Error: #{e.message}" } end
Version data entries
13 entries across 13 versions & 2 rubygems