bin/ws_shootout in plezi-0.15.1 vs bin/ws_shootout in plezi-0.16.0
- old
+ new
@@ -10,31 +10,30 @@
Dir.chdir(File.expand_path(File.join('..', '..', 'lib'), __FILE__))
require 'bundler/setup'
require 'plezi'
class ShootoutApp
+ CHANNEL = "shootout".freeze
# the default HTTP response
def index
"This application should be used with the websocket-shootout benchmark utility."
end
def on_open
- subscribe channel: "shootout"
+ subscribe CHANNEL
end
# we won't be using AutoDispatch, but directly using the `on_message` callback.
def on_message data
if data[0] == 'b' # binary
- publish(channel: "shootout", message: data)
+ publish(CHANNEL, data)
data[0] = 'r'
write data
return
end
cmd, payload = JSON(data).values_at('type', 'payload')
if cmd == 'echo'
write({type: 'echo', payload: payload}.to_json)
else
- # data = {type: 'broadcast', payload: payload}.to_json
- # broadcast :push2client, data
- publish(channel: "shootout", message: ({type: 'broadcast', payload: payload}.to_json))
+ publish(CHANNEL, ({type: 'broadcast', payload: payload}.to_json))
write({type: "broadcastResult", payload: payload}.to_json)
end
rescue
puts "Incoming message format error - not JSON?"
end