Created
March 16, 2011 10:12
-
-
Save bka/872279 to your computer and use it in GitHub Desktop.
websocket client example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'em-http-request' | |
require 'active_support' | |
EventMachine.run { | |
$http = EventMachine::HttpRequest.new("ws://localhost:8080/").get :timeout => 0 | |
$http.errback { |e| puts "oops #{e}" } | |
$http.callback { | |
puts "WebSocket connected!" | |
$http.send("server_version"); | |
$http.send("user_online"); | |
} | |
$http.stream { |msg| | |
puts "Got: #{msg}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment