sinatra-multi-screen 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,8 @@
1
- === 0.0.3 2013-02-14
1
+ === 0.0.4 2013-02-24
2
+
3
+ * catch client-side events on server
4
+
5
+ === 0.0.3 2013-02-24
2
6
 
3
7
  * add simple sample application
4
8
  * refact
data/README.md CHANGED
@@ -92,6 +92,26 @@ remote.on("mode", function(data){
92
92
  });
93
93
  ```
94
94
 
95
+
96
+ ### Events on Server
97
+
98
+ Sinatra Side
99
+ ```ruby
100
+ MultiScreen.on :connect do |client|
101
+ puts "new client #{client.inspect}"
102
+ p MultiScreen.channels
103
+ end
104
+
105
+ MultiScreen.on :disconnect do |client|
106
+ puts "client disconnect - #{client.inspect}"
107
+ p MultiScreen.channels
108
+ end
109
+
110
+ MultiScreen.on :ui_event do |data, from|
111
+ puts "Remote --(dispatch UI Event)--> TV"
112
+ end
113
+ ```
114
+
95
115
  Samples
96
116
  -------
97
117
  * https://github.com/shokai/sinatra-multi-screen/tree/master/sample
@@ -31,8 +31,8 @@ var MultiScreen = function(cometio, options){
31
31
  })
32
32
 
33
33
  if(options.type == "remote"){
34
- this.tv.event = function(selector, event_name, args){
35
- self.tv.push("ui_event", {selector: selector, event: event_name, args: args});
34
+ this.tv.event = function(selector, event_name, arg){
35
+ self.tv.push("ui_event", {selector: selector, event: event_name, arg: arg});
36
36
  };
37
37
  this.tv.$ = function(selector){
38
38
  return {
@@ -65,10 +65,10 @@ var MultiScreen = function(cometio, options){
65
65
  self.remote.on("ui_event", function(data){
66
66
  if(typeof data.selector === 'undefined' ||
67
67
  typeof data.event === 'undefined') return;
68
- if(typeof data.args === 'undefined'){
68
+ if(typeof data.arg === 'undefined'){
69
69
  $(data.selector)[data.event]();
70
70
  }else{
71
- $(data.selector)[data.event](data.args);
71
+ $(data.selector)[data.event](data.arg);
72
72
  }
73
73
  });
74
74
  }
@@ -1,3 +1,3 @@
1
1
  module SinatraMultiScreen
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -10,6 +10,7 @@ module Sinatra
10
10
  unless MultiScreen.channels[opts["channel"]][opts["type"]].include? from
11
11
  raise StandardError, "client <#{from}> is not member of channel <#{opts['channel']}>"
12
12
  end
13
+ MultiScreen.emit data["event"], data["data"], {:session => from, :channel => opts["channel"], :type => opts["type"]}
13
14
  type = case opts["type"]
14
15
  when "tv"
15
16
  "remote"
@@ -18,6 +18,10 @@ MultiScreen.on :disconnect do |client|
18
18
  p MultiScreen.channels
19
19
  end
20
20
 
21
+ MultiScreen.on :ui_event do |data, from|
22
+ puts "UI Event $('#{data['selector']}').#{data['event']}(#{data['arg']}) -- from #{from.inspect}"
23
+ end
24
+
21
25
  before '/*' do
22
26
  @title = app_name
23
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-multi-screen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: