simplepubsub 1.1.14 → 1.2.0

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
1
  ---
2
2
  SHA1:
3
- metadata.gz: 402cc0c47c92fbb6d31edab18f5ef602f4ebe032
4
- data.tar.gz: be5e324d71c9f37d416dfd3caec105871afaddda
3
+ metadata.gz: 0b7490e4aeeacc8821ee174e35b70df351298ec6
4
+ data.tar.gz: fa80ab134536a7283cf6f8575962d8915d842aa4
5
5
  SHA512:
6
- metadata.gz: a0497b8058d23155cc0e5a3206fdb4e080a1c88d7aec5d21a7aa61ba1353b27add3e05af8ac01fab8c40245448e0f2ceef39c01cd1715f84546aba40d656a0ba
7
- data.tar.gz: 283b1f4f1d5f573425d3b7a01a7d2e1d0c3d447ff18cde81bc00c223d55a0efe61adacaeae38be7c6ae118b7573f80d851fa3b6439b48679de6c1ed5cd8ee44a
6
+ metadata.gz: c0c65ceeb1fa9945436d03ca63be5246d27558864b4086ee66be9edfe9e8cb1a6fc4bcf97619b68e08468199c7d2ab11d7bfb83b66a0e640fd17c4d670ff7865
7
+ data.tar.gz: 11021d83a5849aeb2cac03ed02bfc5ca82fc1045c9dadf254461f834f9e2bf0714eb1c11998726e1cbb1908c1112624c8c88434758da764327481c9fc77b0a76
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/simplepubsub.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # file: simplepubsub.rb
4
4
 
5
5
  require 'websocket-eventmachine-server'
6
- require 'websocket-eventmachine-client'
7
6
  require 'xml-registry'
8
7
 
9
8
 
@@ -84,123 +83,10 @@ module SimplePubSub
84
83
  end
85
84
  end
86
85
 
87
- class Client
88
-
89
- class PubSub
90
-
91
- attr_reader :proc, :topic, :message
92
-
93
- def get(topic, options={}, &get_proc)
94
-
95
- @topic = 'subscribe to topic'
96
- @proc, @message = get_proc, topic
97
- end
98
-
99
- def publish(*args)
100
-
101
- topic, message = args.length > 1 ? args : args.first.split(':',2)
102
-
103
- @topic, @message = topic, message
104
- @proc = ->(_,_){}
105
- end
106
- end
107
-
108
- def self.connect(hostname, port: '59000', auto_retry: false, &connect_blk)
109
-
110
- retry_count = nil
111
- pubsub = PubSub.new
112
- connect_blk.call(pubsub)
113
-
114
- blk = lambda do |ws, pubsub, em_already_running|
115
-
116
- ws.onopen do
117
- puts "Connected"
118
- retry_count = 0
119
- end
120
-
121
- ws.onmessage do |msg, type|
122
-
123
- a = msg.split(/\s*:\s*/,2)
124
- topic, message = a
125
- EM.defer {pubsub.proc.call topic, message}
126
-
127
- end
128
-
129
- ws.onclose do
130
-
131
-
132
- if auto_retry and retry_count and retry_count <= 3 then
133
- puts "Disconnected"
134
-
135
- # reconnect within a minute
136
- seconds = rand(60)
137
-
138
- seconds.downto(1) do |i|
139
- s = "reconnecting in %s seconds" % i;
140
- print s
141
- sleep 1
142
- print "\b" * s.length
143
- end
144
- puts
145
-
146
-
147
- self.connect hostname, port: port, retry_count: retry_count+1, &connect_blk
148
- else
149
- puts 'Unable to connect' if auto_retry
150
- end
151
- end
152
-
153
- EventMachine.next_tick do
154
- ws.send pubsub.topic + ': ' + pubsub.message
155
- end
156
-
157
- end
158
-
159
- address = hostname + ':' + port
160
- params = {uri: 'ws://' + address}
161
- c = WebSocket::EventMachine::Client
162
-
163
- begin
164
-
165
- # attempt to run a websocket assuming the EventMachine is
166
- # already running
167
-
168
- ws = c.connect(params)
169
- blk.call ws, pubsub, em_already_running = true
170
- rescue
171
-
172
- thread = Thread.new do
173
- EM.run do
174
-
175
- ws = c.connect(params)
176
- blk.call(ws, pubsub, em_already_running = false)
177
- end
178
- end
179
- thread.join
180
- end
181
-
182
- end
183
- end
184
86
  end
185
87
 
186
88
  if __FILE__ == $0 then
187
89
 
188
- # Server example
189
90
  SimplePubSub::Broker.start
190
91
 
191
- =begin
192
-
193
- # Subscribe example
194
- SimplePubSub::Client.connect('localhost') do |client|
195
- client.get('test') do |topic, message|
196
- puts "#{topic}: #{message}"
197
- end
198
- end
199
-
200
- # Publish example
201
- SimplePubSub::Client.connect('localhost') do |client|
202
- client.publish('test', Time.now.to_s)
203
- end
204
-
205
- =end
206
- end
92
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplepubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.14
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -12,26 +12,26 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE0MDcxNjEyMzUzMloXDTE1MDcxNjEyMzUzMlowSDESMBAG
15
+ 8ixkARkWAmV1MB4XDTE1MTAwOTA1MjkxNFoXDTE2MTAwODA1MjkxNFowSDESMBAG
16
16
  A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
17
  EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAK6Q3hJvYMyIqt8HYWLuI8pquJwloqnrxpF7iwbHL45bZQt1w4jJcFUNgY0W
19
- NrXuf63A/CXYzJT/QHIYd5D+DODf7yOUto9zo9/sxZR2vsr2K2hNteSjDiXGcznl
20
- YjZoiYSRz9HsN+cIueQy/buriC5b5L+7TifP8xCMrB5ArR1G8g5XiIa5wu4IAPLK
21
- ScrJZJvvqp4mKYypOZLCNTgAALUyZL4dZ0apevj7y1RJmR93MQp938nnPhbpHELa
22
- RVfLuPew9y692PcZhYupGoIOL6VLZMOGpNJHuIaE922K4mSXHRgrHCHDDLOUhhEf
23
- 98bBxW6fHQVR9vBRSLej30BHMb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AlYVp2pAKbkXkbTn
32
- EkYZt+RIxgYhhw==
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAOni98I5r
27
+ gyrZ6KEa14BrmgO/ohp5zUWWry67SS6Iw95KL/e1koOiY0C74c7uL9x1h6kb+F38
28
+ TGjMF7xmAfjFsFalOIpmpGMHqrTSA36lzTCw7PSSDDWM5Y98HJLRzX+y+Xlech9W
29
+ TbQQDs4sT8Bw2w7g3IzXrlj1+XiytFwLUTauE6+FdhhSaCvJBzwV7VhC3eAeIYvx
30
+ hA7pXn7vTl8mPLKS2zY1xziPJQA+hYj+5EBeND89eWFYPR9f+Qc+/KM91PQU/29K
31
+ kIiwfbNsuzjbgWzdKm7Rmqd2eqM34Vn+TRGopqMQ8lTxyrQst+2LQnDV0BVrkl+h
32
+ GtYDHIOX5GPNIg==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-06-13 00:00:00.000000000 Z
34
+ date: 2015-10-09 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: websocket-eventmachine-server
@@ -53,26 +53,6 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.0.1
56
- - !ruby/object:Gem::Dependency
57
- name: websocket-eventmachine-client
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.0'
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 1.1.0
66
- type: :runtime
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '1.0'
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.1.0
76
56
  - !ruby/object:Gem::Dependency
77
57
  name: xml-registry
78
58
  requirement: !ruby/object:Gem::Requirement
@@ -120,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
100
  version: '0'
121
101
  requirements: []
122
102
  rubyforge_project:
123
- rubygems_version: 2.4.6
103
+ rubygems_version: 2.4.8
124
104
  signing_key:
125
105
  specification_version: 4
126
- summary: simplepubsub
106
+ summary: The SimplePubSub gem is a messaging broker which uses Eventmachine + websockets.
127
107
  test_files: []
metadata.gz.sig CHANGED
Binary file