simplepubsub 1.0.4 → 1.1.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/simplepubsub.rb +26 -14
- data.tar.gz.sig +0 -0
- metadata +17 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5c822fc449cb17e0be9b54fd7983047dcf25c7
|
4
|
+
data.tar.gz: be521eac2afbce4ad9a7d3aaf7741025bbf89f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd64f0bc0f6def5d6d8d6eb2d6d281f29ad7167ec635aef451fd80f637345569d5f8fc0afb9b321d05a2a130ef00839f8b001c07fae49498401d0efbc117bac1
|
7
|
+
data.tar.gz: 3a1bea9cb8a20c1e572fb7969b77ba36ba16df990e64663d4c097c6cdbe7654df2d891e02ed893efed5fe83164fef1fd5916578a3ed4f36fc844755d612b6a24
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/simplepubsub.rb
CHANGED
@@ -4,16 +4,15 @@
|
|
4
4
|
|
5
5
|
require 'websocket-eventmachine-server'
|
6
6
|
require 'websocket-eventmachine-client'
|
7
|
+
require 'xml-registry'
|
7
8
|
|
8
9
|
|
9
10
|
module SimplePubSub
|
10
11
|
|
11
12
|
class Server
|
12
13
|
|
13
|
-
def start(
|
14
|
+
def start(host: '0.0.0.0', port: 59000)
|
14
15
|
|
15
|
-
opt = {host: '0.0.0.0', port: 59000}.merge options
|
16
|
-
host, port = opt[:host], opt[:port]
|
17
16
|
|
18
17
|
EM.run do
|
19
18
|
|
@@ -37,10 +36,11 @@ module SimplePubSub
|
|
37
36
|
|
38
37
|
if a.first == 'subscribe to topic' then
|
39
38
|
|
40
|
-
topic = a.last.rstrip
|
39
|
+
topic = a.last.rstrip #.gsub('+','*').gsub('#','//')
|
41
40
|
subscribers[topic] ||= []
|
42
41
|
subscribers[topic] << ws
|
43
42
|
|
43
|
+
# affix the topic to the subscriber's websocket
|
44
44
|
def ws.subscriber_topic=(topic) @topic = topic end
|
45
45
|
def ws.subscriber_topic() @topic end
|
46
46
|
|
@@ -49,16 +49,25 @@ module SimplePubSub
|
|
49
49
|
elsif a.length > 1
|
50
50
|
|
51
51
|
puts "publish this %s: %s" % a
|
52
|
-
|
52
|
+
current_topic, message = a
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
54
|
+
reg = XMLRegistry.new
|
55
|
+
reg[current_topic] = message
|
57
56
|
|
58
|
-
|
59
|
-
|
57
|
+
subscribers.each do |topic,conns|
|
58
|
+
if reg[topic] then
|
59
|
+
conns.each {|x| x.send current_topic + ': ' + message}
|
60
|
+
end
|
60
61
|
end
|
61
62
|
|
63
|
+
#if subscribers[topic] then
|
64
|
+
# subscribers[topic].each {|c| c.send topic + ': ' + message }
|
65
|
+
#end
|
66
|
+
|
67
|
+
#if subscribers['#'] then
|
68
|
+
# subscribers['#'].each {|c| c.send topic + ': ' + message }
|
69
|
+
#end
|
70
|
+
|
62
71
|
#ws.send msg, :type => type
|
63
72
|
|
64
73
|
end
|
@@ -96,7 +105,7 @@ module SimplePubSub
|
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
99
|
-
def self.connect(hostname, port='59000')
|
108
|
+
def self.connect(hostname, port='59000', options={})
|
100
109
|
|
101
110
|
pubsub = PubSub.new
|
102
111
|
yield(pubsub)
|
@@ -141,10 +150,13 @@ module SimplePubSub
|
|
141
150
|
blk.call ws, pubsub, em_already_running = true
|
142
151
|
rescue
|
143
152
|
|
144
|
-
|
145
|
-
|
146
|
-
|
153
|
+
thread = Thread.new do
|
154
|
+
EM.run do
|
155
|
+
ws = c.connect(params)
|
156
|
+
blk.call(ws, pubsub, em_already_running = false)
|
157
|
+
end
|
147
158
|
end
|
159
|
+
thread.join
|
148
160
|
end
|
149
161
|
|
150
162
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
i0PBE6fLwlIMk8jNNUcX3J1csSMgLNTwE8CwrlSZE8sueHj0pQzICM7lF0gGREO6
|
32
32
|
hQHD0LljU3MusQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: websocket-eventmachine-server
|
@@ -61,6 +61,20 @@ dependencies:
|
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: xml-registry
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
64
78
|
description:
|
65
79
|
email: james@r0bertson.co.uk
|
66
80
|
executables: []
|
@@ -88,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
102
|
version: '0'
|
89
103
|
requirements: []
|
90
104
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.1.11
|
92
106
|
signing_key:
|
93
107
|
specification_version: 4
|
94
108
|
summary: simplepubsub
|
metadata.gz.sig
CHANGED
Binary file
|