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

Version Path
em-websocket-0.5.3 examples/ping.rb
em-websocket-0.5.2 examples/ping.rb
sonixlabs-em-websocket-0.5.1.5 examples/ping.rb
sonixlabs-em-websocket-0.5.1.4 examples/ping.rb
sonixlabs-em-websocket-0.5.1.3 examples/ping.rb
sonixlabs-em-websocket-0.5.1.2 examples/ping.rb
sonixlabs-em-websocket-0.5.1.1 examples/ping.rb
em-websocket-0.5.1 examples/ping.rb
em-websocket-0.5.0 examples/ping.rb
em-websocket-0.4.0 examples/ping.rb
em-websocket-0.3.8 examples/ping.rb
em-websocket-0.3.7 examples/ping.rb
em-websocket-0.3.6 examples/ping.rb