sinatra-cometio 0.3.1 → 0.3.2

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.3.2 2013-03-16
2
+
3
+ * fix README
4
+
1
5
  === 0.3.1 2013-03-16
2
6
 
3
7
  * fix dependencies
data/README.md CHANGED
@@ -34,8 +34,10 @@ set :cometio, :timeout => 120
34
34
  run Sinatra::Application
35
35
  ```
36
36
  ```ruby
37
- cometio.push :temperature, 35 # to all clients
38
- cometio.push :light, {:value => 150}, {:to => session_id} # to specific client
37
+ io = Sinatra::CometIO
38
+
39
+ io.push :temperature, 35 # to all clients
40
+ io.push :light, {:value => 150}, {:to => session_id} # to specific client
39
41
  ```
40
42
 
41
43
  Client Side
@@ -66,7 +68,7 @@ io.push("chat", {name: "shokai", message: "hello"}); // client -> server
66
68
  Server Side
67
69
 
68
70
  ```ruby
69
- cometio.on :chat do |data, session|
71
+ io.on :chat do |data, session|
70
72
  puts "#{data['name']} : #{data['message']} <#{session}>"
71
73
  end
72
74
  ## => "shokai : hello <12abcde345f6g7h8ijk>"
@@ -85,11 +87,11 @@ io.on("connect", function(session){
85
87
  Server Side
86
88
 
87
89
  ```ruby
88
- cometio.on :connect do |session|
90
+ io.on :connect do |session|
89
91
  puts "new client <#{session}>"
90
92
  end
91
93
 
92
- cometio.on :disconnect do |session|
94
+ io.on :disconnect do |session|
93
95
  puts "client disconnected <#{session}>"
94
96
  end
95
97
  ```
@@ -109,16 +111,16 @@ io.on("error", function(err){
109
111
  Server Side
110
112
 
111
113
  ```ruby
112
- event_id = cometio.on :chat do |data, from|
114
+ event_id = io.on :chat do |data, from|
113
115
  puts "#{data} - from#{from}"
114
116
  end
115
- cometio.removeListener event_id
117
+ io.removeListener event_id
116
118
  ```
117
119
 
118
120
  or
119
121
 
120
122
  ```ruby
121
- cometio.removeListener :chat # remove all "chat" listener
123
+ io.removeListener :chat # remove all "chat" listener
122
124
  ```
123
125
 
124
126
 
@@ -6,7 +6,7 @@ module Sinatra
6
6
  end
7
7
 
8
8
  def cometio
9
- Sinatra::CometIO
9
+ CometIO.options
10
10
  end
11
11
 
12
12
  def self.registered(app)
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
data/sample/main.rb CHANGED
@@ -1,25 +1,26 @@
1
1
  class ChatApp < Sinatra::Base
2
2
  register Sinatra::CometIO
3
+ io = Sinatra::CometIO
3
4
 
4
- cometio.on :chat do |data, from|
5
+ io.on :chat do |data, from|
5
6
  puts "#{data['name']} : #{data['message']} (from:#{from})"
6
7
  push :chat, data
7
8
  end
8
9
 
9
- cometio.on :connect do |session|
10
+ io.on :connect do |session|
10
11
  puts "new client <#{session}>"
11
12
  push :chat, {:name => "system", :message => "new client <#{session}>"}
12
13
  push :chat, {:name => "system", :message => "welcome <#{session}>"}, {:to => session}
13
14
  end
14
15
 
15
- cometio.on :disconnect do |session|
16
+ io.on :disconnect do |session|
16
17
  puts "disconnect client <#{session}>"
17
18
  push :chat, {:name => "system", :message => "bye <#{session}>"}
18
19
  end
19
20
 
20
21
  EM::defer do
21
22
  loop do
22
- cometio.push :chat, :name => 'clock', :message => Time.now.to_s
23
+ io.push :chat, :name => 'clock', :message => Time.now.to_s
23
24
  sleep 60
24
25
  end
25
26
  end
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.3.1
4
+ version: 0.3.2
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: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack