Sha256: f00cb2be62c5038955c73a797902a08d1c748bef74b2003c7096556ad9aa21cf
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
#!/usr/bin/env ruby # encoding: UTF-8 require 'benchmark' $LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__ ) require "plezi" require "bundler/setup" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. # (If you use this, don't forget to add pry to your Gemfile!) # require "pry" # Pry.start class DispatchTest @auto_dispatch = true def before {event: :failed, data: :forbidden}.to_json end def _hidden {event: :failed, data: :forbidden}.to_json end def test data = {} data[:data] ||= "test" {event: 'alert', data: data[:data]}.to_json end def index event = nil %q{<html><head><script src='/client.js'></script> </head> <body> <button onclick='connection.emit({event: "test", data: "Woohooo!"});' value='test'>Test!</button> <script> document.body.onload = function() { connection = new PleziClient(); connection.alert = function(data) { alert(JSON.stringify(data)); console.log(data); } connection.err = function(data) { alert("Error: " + JSON.stringify(data)); console.log(data); } connection.emit_timeout = 3000; connection.unknown = function(data) { alert("Unknown event: " + JSON.stringify(data)); console.log(data); } } </script></body></html>} end end host route '/client.js', :client route '/', DispatchTest
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plezi-0.12.19 | test/dispatch |