Sha256: 2bd80bc53e91c9246801e42c12a50ec89584abbe59a82ee758ffe173290c2907

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 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
		%q{<html><head><script src='/assets/plezi_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.onalert = function(data) {
		alert(JSON.stringify(data));
		console.log(data);
	}
//	connection.onerr = function(data) {
//		alert("Error: " + JSON.stringify(data));
//		console.log(data);
//	}
	connection.unknown = function(data) {
		alert("Unknown event: " + JSON.stringify(data));
		console.log(data);
	}
}
</script></body></html>}
	end
end
host assets: File.expand_path(File.join('..','..', 'resources'), __FILE__)
route '/', DispatchTest

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plezi-0.12.18 test/dispatch