sinatra-cometio 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.0.6 2012-11-17
2
+
3
+ * fix README
4
+ * fix gem require
5
+
1
6
  === 0.0.5 2012-11-16
2
7
 
3
8
  * add github page link
data/README.rdoc CHANGED
@@ -19,7 +19,14 @@ Node.js like Comet I/O plugin for Sinatra
19
19
 
20
20
  == SYNOPSIS:
21
21
 
22
- === Client --(Ajax)--> Server
22
+ === Server --(Comet)--> Client
23
+
24
+ Server Side
25
+
26
+ require 'sinatra'
27
+ require 'sinatra/cometio'
28
+ CometIO.push :temperature, 35 # to all clients
29
+ CometIO.push :light, {:value => 150}, {:to => session_id} # to specific client
23
30
 
24
31
  Client Side
25
32
 
@@ -27,38 +34,31 @@ Client Side
27
34
  <script src="<%= cometio_js %>"></script>
28
35
 
29
36
  var io = new CometIO().connect();
37
+ io.on("temperature", function(value){
38
+ console.log("server temperature : " + value);
39
+ }); // => "server temperature : 35"
40
+ io.on("light", function(data){
41
+ console.log("server light sensor : + data.value);
42
+ }); // => "server light sensor : 150"
43
+
44
+ === Client --(Ajax)--> Server
45
+
46
+ Client Side
47
+
30
48
  io.push("chat", {name: "shokai", message: "hello"}); // client -> server
31
49
 
32
50
  Server Side
33
51
 
34
- require 'sinatra'
35
- require 'sinatra/cometio'
36
-
37
52
  CometIO.on :chat do |data, session|
38
53
  puts "#{data['name']} : #{data['message']} <#{session}>"
39
54
  end
40
55
  ## => "shokai : hello <12abcde345f6g7h8ijk>"
41
56
 
42
-
43
- === Server --(Comet)--> Client
44
-
45
- Server Side
46
-
47
- CometIO.push :temperature, 35 # broadcast
48
- CometIO.push :light, {:value => 150}, {:to => session_id} # to specific client
49
-
50
- Client Side
51
-
52
- io.on("temperature", function(value){
53
- console.log("server temperature : " + value);
54
- });
55
-
56
-
57
57
  === On "connect" Event
58
58
 
59
59
  Client Side
60
60
 
61
- io.on("connect",function(session){
61
+ io.on("connect", function(session){
62
62
  alert("connect!!");
63
63
  });
64
64
 
@@ -88,7 +88,7 @@ Server Side
88
88
 
89
89
  or
90
90
 
91
- CometIO.removeListener :chat # remove all chat listener
91
+ CometIO.removeListener :chat # remove all "chat" listener
92
92
 
93
93
 
94
94
  Client Side
@@ -100,7 +100,7 @@ Client Side
100
100
 
101
101
  or
102
102
 
103
- io.removeListener("error"); // remove all error listener
103
+ io.removeListener("error"); // remove all "error" listener
104
104
 
105
105
  == Sample App
106
106
 
@@ -1,3 +1,3 @@
1
1
  module SinatraCometio
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -1,3 +1,4 @@
1
+ require 'eventmachine'
1
2
  require 'json'
2
3
  require 'digest/md5'
3
4
  require 'event_emitter'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cometio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: 2993998207114587225
197
+ hash: 1827683749914506079
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  none: false
200
200
  requirements: