bin/ws_shootout in plezi-0.14.6 vs bin/ws_shootout in plezi-0.14.7
- old
+ new
@@ -6,10 +6,11 @@
# ENV['PL_REDIS_URL'] ||= "redis://:password@my.host:6389/0"
Dir.chdir(File.expand_path(File.join('..', '..', 'lib'), __FILE__))
require 'bundler/setup'
require 'plezi'
+
class ShootoutApp
# the default HTTP response
def index
"This application should be used with the websocket-shootout benchmark utility."
end
@@ -17,14 +18,21 @@
def on_message data
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
ShootoutApp.write2everyone({type: 'broadcast', payload: payload}.to_json)
write({type: "broadcastResult", payload: payload}.to_json)
end
rescue
puts "Incoming message format error - not JSON?"
end
+
+ def push2client data
+ write data
+ end
+
end
Plezi.route '*', ShootoutApp