File: websocket-server.rb

package info (click to toggle)
ruby-em-http-request 0.3.0-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 424 kB
  • sloc: ruby: 2,381; ansic: 999; makefile: 2
file content (8 lines) | stat: -rw-r--r-- 278 bytes parent folder | download
1
2
3
4
5
6
7
8
require 'rubygems'
require 'em-websocket'

EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
  ws.onopen    { ws.send "Hello Client!"}
  ws.onmessage { |msg| p "got: #{msg}"; ws.send "Pong: #{msg}" }
  ws.onclose   { puts "WebSocket closed" }
end