Skip to content

Commit

Permalink
update websocket test code
Browse files Browse the repository at this point in the history
  • Loading branch information
inosin committed Apr 10, 2013
1 parent 550e0a4 commit 1c34d1c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
ruby websocket connection test

###with em-websocket 0.5.0
bundle exec ruby websocket.rb
bundle exec ruby websocket1.rb
bundle exec ruby websocket2.rb

###with em-websocket 0.3.8
bundle exec ruby websocket_old.rb
bundle exec ruby websocket1.rb
bundle exec ruby websocket2.rb
bundle exec ruby goliath_websocket.rb -e prod -sv -p 8080
16 changes: 0 additions & 16 deletions websocket.rb

This file was deleted.

9 changes: 9 additions & 0 deletions websocket1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'em-websocket'

# Start WebSocket server, including starting eventmachine run loop
EM::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
ws.onopen { |handshake| puts "WebSocket opened" }
ws.onmessage { |msg| ws.send "Pong: #{msg}" }
ws.onclose { puts "WebSocket closed" }
ws.onerror { |e| puts "Error: #{e.message}" }
end
17 changes: 17 additions & 0 deletions websocket2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'em-websocket'

EM.run {
EM.start_server('0.0.0.0', 8080, EM::WebSocket::Connection, :debug => false) do |ws|
# only em-websocket 0.5.0 support
# ws.onopen { |handshake|puts "WebSocket opened #{{
# :path => handshake.path,
# :query => handshake.query,
# :origin => handshake.origin,
# }}"
# }
ws.onopen { puts "WS opening"}
ws.onmessage { |msg| ws.send "Pong: #{msg}" }
ws.onclose { puts "WebSocket closed" }
ws.onerror { |e| puts "Error: #{e.message}" }
end
}
11 changes: 0 additions & 11 deletions websocket_old.rb

This file was deleted.

0 comments on commit 1c34d1c

Please sign in to comment.