em-rocketio-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 73c3e96f63c492b52c174596344048f96502f8d4
4
- data.tar.gz: 78e0270cd3237bed4b15ae2ba97e5672c92da047
5
- SHA512:
6
- metadata.gz: 65d4c4fd36d901dd438582f71cbbfb4dfcad06b0ecabe39dcc211d8bd8353d6ab200274e5a750d5d1fdefdc2b834a94ad02ecd022028abf876582dd26b00fc71
7
- data.tar.gz: 4aab374035d2a010300d929a994f8ae7683b4d27996c9a3462a59734a097d28103e002bddb0855bf92085a035b63b3c61efcac6582931da8a25784ddd4009f42
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea217c13dfc2f0babb7a69266abf890151b20766
4
+ data.tar.gz: 2d0fb7c526e0e137b8f1c1266876da36ee7ff38d
5
+ SHA512:
6
+ metadata.gz: 083d68b20a111a0504a7b5581bd4fb1c6ff23fe013877720a448745f01f7175a392cf11e174e3646a183106c5f2f23e594e77f7612e3ff898f35ac216a2ba9e6
7
+ data.tar.gz: 1b75d74437a43e6977230aed0ef6e33d75f64ad004d889f7479c91ef990a2fa37c89baf970d11672b170314052a69be98bb8b35ab4f579507a38ca554956cb56
@@ -1,3 +1,7 @@
1
+ === 0.1.2 2013-07-12
2
+
3
+ * cache /settings
4
+
1
5
  === 0.1.1 2013-04-01
2
6
 
3
7
  * bugfix for duplicative comet "connect" event
data/README.md CHANGED
@@ -21,8 +21,8 @@ EM::run do
21
21
  io = EM::RocketIO::Client.new('http://localhost:5000').connect
22
22
  # io = EM::RocketIO::Client.new('http://localhost:5000', :type => :comet).connect
23
23
  # io = EM::RocketIO::Client.new('http://localhost:5000', :channel => '1').connect
24
- io.on :connect do |session|
25
- puts "#{io.type} connect!! (sessin_id:#{session})"
24
+ io.on :connect do
25
+ puts "#{io.type} connect!! (sessin_id:#{io.session})"
26
26
  end
27
27
 
28
28
  io.on :disconnect do
@@ -51,10 +51,11 @@ Sample
51
51
 
52
52
  start [chat server](https://github.com/shokai/rocketio-chat-sample)
53
53
 
54
- % git clone git://github.com/shokai/rocketio-chat-sample.git
55
- % cd rocketio-chat-sample
54
+ % git clone git://github.com/shokai/sinatra-rocketio.git
55
+ % cd sinatra-rocketio
56
56
  % bundle install
57
- % foreman start
57
+ % cd sample/classic_style
58
+ % rackup config.ru -p 5000
58
59
 
59
60
  => http://localhost:5000
60
61
 
@@ -64,7 +65,6 @@ sample chat client
64
65
  % ruby sample/cui_chat_client.rb
65
66
  % ruby sample/cui_chat_client.rb http://localhost:5000 comet
66
67
  % ruby sample/cui_chat_client.rb http://localhost:5000 websocket
67
- % ruby sample/cui_chat_client.rb http://rocketio-chat.herokuapp.com
68
68
 
69
69
 
70
70
  Test
@@ -76,7 +76,7 @@ Test
76
76
  start server
77
77
 
78
78
  % export PORT=5000
79
- % export WS_PORT=8080
79
+ % export WS_PORT=9000
80
80
  % rake test_server
81
81
 
82
82
  run test
@@ -7,6 +7,10 @@ module EventMachine
7
7
  include EventEmitter
8
8
  attr_reader :settings, :type, :io, :channel
9
9
 
10
+ def self.settings
11
+ @@settings ||= {}
12
+ end
13
+
10
14
  public
11
15
  def initialize(url, opt={:type => :websocket, :channel => nil})
12
16
  @url = url
@@ -25,11 +29,17 @@ module EventMachine
25
29
 
26
30
  private
27
31
  def get_settings
32
+ if self.class.settings[@url].kind_of? Hash
33
+ @settings = self.class.settings[@url]
34
+ emit :__settings
35
+ return
36
+ end
28
37
  url = "#{@url}/rocketio/settings"
29
38
  http = EM::HttpRequest.new(url).get
30
39
  http.callback do |res|
31
40
  begin
32
41
  @settings = JSON.parse res.response
42
+ self.class.settings[@url] = @settings
33
43
  emit :__settings
34
44
  rescue => e
35
45
  emit :error, "#{e} (#{url})"
@@ -1,7 +1,7 @@
1
1
  module EventMachine
2
2
  module RocketIO
3
3
  class Client
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ class App
9
9
  end
10
10
 
11
11
  def self.ws_port
12
- ENV['WS_PORT'] || 8080
12
+ ENV['WS_PORT'] || 9000
13
13
  end
14
14
 
15
15
  def self.url
@@ -1,6 +1,6 @@
1
1
  require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestChannel < MiniTest::Unit::TestCase
3
+ class TestChannel < MiniTest::Test
4
4
 
5
5
  def test_channel
6
6
  ## client1(comet, channel "aaa") ---> server --> client3(websocket, channel "aaa")
@@ -34,11 +34,10 @@ class TestChannel < MiniTest::Unit::TestCase
34
34
  end
35
35
 
36
36
  EM::defer do
37
- 50.times do
37
+ 80.times do
38
38
  break if res != nil and res3 != nil
39
39
  sleep 0.1
40
40
  end
41
- client.close
42
41
  EM::stop
43
42
  end
44
43
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestEmRocketioClient < MiniTest::Unit::TestCase
3
+ class TestEmRocketioClient < MiniTest::Test
4
4
 
5
5
  def test_websocket_to_comet
6
6
  ## websocket --> server --> comet
@@ -39,17 +39,19 @@ class TestEmRocketioClient < MiniTest::Unit::TestCase
39
39
  end
40
40
 
41
41
  EM::defer do
42
- 50.times do
42
+ 80.times do
43
43
  break if res != nil
44
44
  sleep 0.1
45
45
  end
46
- client.close
46
+ EM::add_timer 1 do
47
+ EM::stop
48
+ end
47
49
  end
48
50
  end
49
51
  assert res2 != nil, 'server not respond'
50
- assert res2["time"] == post_data[:time]
51
- assert res2["msg"] == post_data[:msg]
52
- assert res == nil
52
+ assert_equal res2["time"], post_data[:time]
53
+ assert_equal res2["msg"], post_data[:msg]
54
+ assert_equal res, nil
53
55
  end
54
56
 
55
57
  def test_comet_to_websocket
@@ -83,20 +85,19 @@ class TestEmRocketioClient < MiniTest::Unit::TestCase
83
85
  end
84
86
 
85
87
  EM::defer do
86
- 50.times do
88
+ 80.times do
87
89
  break if res != nil
88
90
  sleep 0.1
89
91
  end
90
- client.close
91
92
  EM::add_timer 1 do
92
93
  EM::stop
93
94
  end
94
95
  end
95
96
  end
96
97
  assert res2 != nil, 'server not respond'
97
- assert res2["time"] == post_data[:time]
98
- assert res2["msg"] == post_data[:msg]
99
- assert res == nil
98
+ assert_equal res2["time"], post_data[:time]
99
+ assert_equal res2["msg"], post_data[:msg]
100
+ assert_equal res, nil
100
101
  end
101
102
 
102
103
  end
metadata CHANGED
@@ -1,111 +1,162 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: em-rocketio-client
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2013-04-01 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
19
17
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: "1.3"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
22
20
  type: :development
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: rake
26
21
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - &id003
30
- - ">="
31
- - !ruby/object:Gem::Version
32
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
33
34
  type: :development
34
- version_requirements: *id002
35
- - !ruby/object:Gem::Dependency
36
- name: minitest
37
35
  prerelease: false
38
- requirement: &id004 !ruby/object:Gem::Requirement
39
- requirements:
40
- - *id003
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
41
48
  type: :development
42
- version_requirements: *id004
43
- - !ruby/object:Gem::Dependency
44
- name: sinatra-rocketio
45
49
  prerelease: false
46
- requirement: &id005 !ruby/object:Gem::Requirement
47
- requirements:
48
- - *id003
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra-rocketio
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
49
62
  type: :development
50
- version_requirements: *id005
51
- - !ruby/object:Gem::Dependency
52
- name: thin
53
63
  prerelease: false
54
- requirement: &id006 !ruby/object:Gem::Requirement
55
- requirements:
56
- - *id003
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thin
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
57
76
  type: :development
58
- version_requirements: *id006
59
- - !ruby/object:Gem::Dependency
60
- name: em-cometio-client
61
77
  prerelease: false
62
- requirement: &id007 !ruby/object:Gem::Requirement
63
- requirements:
64
- - *id003
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: em-cometio-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
65
90
  type: :runtime
66
- version_requirements: *id007
67
- - !ruby/object:Gem::Dependency
68
- name: em-websocketio-client
69
91
  prerelease: false
70
- requirement: &id008 !ruby/object:Gem::Requirement
71
- requirements:
72
- - *id003
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: em-websocketio-client
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
73
104
  type: :runtime
74
- version_requirements: *id008
75
- - !ruby/object:Gem::Dependency
76
- name: em-http-request
77
105
  prerelease: false
78
- requirement: &id009 !ruby/object:Gem::Requirement
79
- requirements:
80
- - *id003
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: em-http-request
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
81
118
  type: :runtime
82
- version_requirements: *id009
83
- - !ruby/object:Gem::Dependency
84
- name: eventmachine
85
119
  prerelease: false
86
- requirement: &id010 !ruby/object:Gem::Requirement
87
- requirements:
88
- - *id003
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: eventmachine
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
89
132
  type: :runtime
90
- version_requirements: *id010
91
- - !ruby/object:Gem::Dependency
92
- name: event_emitter
93
133
  prerelease: false
94
- requirement: &id011 !ruby/object:Gem::Requirement
95
- requirements:
96
- - *id003
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: event_emitter
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
97
146
  type: :runtime
98
- version_requirements: *id011
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
99
153
  description: Sinatra RocketIO client for eventmachine
100
- email:
154
+ email:
101
155
  - hashimoto@shokai.org
102
156
  executables: []
103
-
104
157
  extensions: []
105
-
106
158
  extra_rdoc_files: []
107
-
108
- files:
159
+ files:
109
160
  - .gitignore
110
161
  - Gemfile
111
162
  - History.txt
@@ -124,29 +175,30 @@ files:
124
175
  - test/test_em_rocketio_client.rb
125
176
  - test/test_helper.rb
126
177
  homepage: https://github.com/shokai/em-rocketio-client
127
- licenses:
178
+ licenses:
128
179
  - MIT
129
180
  metadata: {}
130
-
131
181
  post_install_message:
132
182
  rdoc_options: []
133
-
134
- require_paths:
183
+ require_paths:
135
184
  - lib
136
- required_ruby_version: !ruby/object:Gem::Requirement
137
- requirements:
138
- - *id003
139
- required_rubygems_version: !ruby/object:Gem::Requirement
140
- requirements:
141
- - *id003
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
142
195
  requirements: []
143
-
144
196
  rubyforge_project:
145
197
  rubygems_version: 2.0.3
146
198
  signing_key:
147
199
  specification_version: 4
148
200
  summary: Sinatra RocketIO client for eventmachine
149
- test_files:
201
+ test_files:
150
202
  - test/app.rb
151
203
  - test/app/config.ru
152
204
  - test/app/main.rb