simplepubsub 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -2
- data/lib/simplepubsub.rb +27 -13
- data.tar.gz.sig +0 -0
- metadata +43 -24
- 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: e4193fc0ed3384cdeb8ab00f6ec6977ec28e1b70
|
4
|
+
data.tar.gz: 0b0b38417f75b4179588093ca183a2d29cf414bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb424c06c857fa76c361f3345f5c1bc4cc311291746cabab853a5e4e57d3dcc2b23b87685cd857006ec9afd6232c8f8198d6c49d6d100a1ad05155b98219e507
|
7
|
+
data.tar.gz: a1709839802a3d0b8b3dba597a2b9ccf94e1b9a3ca4addb5af81a8df7a41eb38655755712ba4203fcecc7022c9b0a08ad99b594b33e83e31343f87749cf33510
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
9�
|
1
|
+
�"�����;��֮��[sH��Q��LY.rf�d�)5��[�3�-�KGo�
|
2
|
+
{7ފtŝ9����j���Qr�m���-Z0�{�Uђ�T,����P���3�h��@E�F��E��c�m(o}c
|
3
|
+
�3�gjH��~���F���"B��n�k�!/f�.ư�dzi�|t5��-L
|
4
|
+
��3�ᩩ�a��/c�2 YѰZo%xlס�b��l,�-9sAɧ���'i&m;峉f����"F���=��i
|
data/lib/simplepubsub.rb
CHANGED
@@ -11,7 +11,7 @@ module SimplePubSub
|
|
11
11
|
|
12
12
|
class Server
|
13
13
|
|
14
|
-
def start(host: '0.0.0.0', port: 59000)
|
14
|
+
def self.start(host: '0.0.0.0', port: 59000)
|
15
15
|
|
16
16
|
|
17
17
|
EM.run do
|
@@ -89,23 +89,25 @@ module SimplePubSub
|
|
89
89
|
|
90
90
|
attr_reader :proc, :topic, :message
|
91
91
|
|
92
|
-
def get(topic,
|
92
|
+
def get(topic, &get_proc)
|
93
93
|
|
94
94
|
@topic = 'subscribe to topic'
|
95
95
|
@proc, @message = get_proc, topic
|
96
96
|
end
|
97
97
|
|
98
|
-
def publish(
|
98
|
+
def publish(*args)
|
99
|
+
|
100
|
+
topic, message = args.length > 1 ? args : args.first.split(':',2)
|
99
101
|
|
100
102
|
@topic, @message = topic, message
|
101
|
-
@proc = ->(_,_){
|
103
|
+
@proc = ->(_,_){}
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
|
-
def self.connect(hostname, port
|
107
|
+
def self.connect(hostname, port: '59000', &connect_blk)
|
106
108
|
|
107
109
|
pubsub = PubSub.new
|
108
|
-
|
110
|
+
connect_blk.call(pubsub)
|
109
111
|
|
110
112
|
blk = lambda do |ws, pubsub, em_already_running|
|
111
113
|
|
@@ -117,16 +119,26 @@ module SimplePubSub
|
|
117
119
|
|
118
120
|
a = msg.split(/\s*:\s*/,2)
|
119
121
|
topic, message = a
|
120
|
-
|
122
|
+
EM.defer {pubsub.proc.call topic, message}
|
121
123
|
|
122
|
-
if r == :stop then
|
123
|
-
ws.close
|
124
|
-
EM.stop if em_already_running == false
|
125
|
-
end
|
126
124
|
end
|
127
125
|
|
128
126
|
ws.onclose do
|
129
127
|
puts "Disconnected"
|
128
|
+
|
129
|
+
# reconnect within a minute
|
130
|
+
seconds = rand(60)
|
131
|
+
|
132
|
+
seconds.downto(1) do |i|
|
133
|
+
s = "reconnecting in %s seconds" % i;
|
134
|
+
print s
|
135
|
+
sleep 1
|
136
|
+
print "\b" * s.length
|
137
|
+
end
|
138
|
+
puts
|
139
|
+
|
140
|
+
|
141
|
+
self.connect hostname, port: port, &connect_blk
|
130
142
|
end
|
131
143
|
|
132
144
|
EventMachine.next_tick do
|
@@ -143,13 +155,15 @@ module SimplePubSub
|
|
143
155
|
|
144
156
|
# attempt to run a websocket assuming the EventMachine is
|
145
157
|
# already running
|
146
|
-
|
158
|
+
|
159
|
+
ws = c.connect(params, &connect_blk)
|
147
160
|
blk.call ws, pubsub, em_already_running = true
|
148
161
|
rescue
|
149
162
|
|
150
163
|
thread = Thread.new do
|
151
164
|
EM.run do
|
152
|
-
|
165
|
+
|
166
|
+
ws = c.connect(params, &connect_blk)
|
153
167
|
blk.call(ws, pubsub, em_already_running = false)
|
154
168
|
end
|
155
169
|
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.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -12,69 +12,87 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE0MDcxNjEyMzUzMloXDTE1MDcxNjEyMzUzMlowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
ggEBAK6Q3hJvYMyIqt8HYWLuI8pquJwloqnrxpF7iwbHL45bZQt1w4jJcFUNgY0W
|
19
|
+
NrXuf63A/CXYzJT/QHIYd5D+DODf7yOUto9zo9/sxZR2vsr2K2hNteSjDiXGcznl
|
20
|
+
YjZoiYSRz9HsN+cIueQy/buriC5b5L+7TifP8xCMrB5ArR1G8g5XiIa5wu4IAPLK
|
21
|
+
ScrJZJvvqp4mKYypOZLCNTgAALUyZL4dZ0apevj7y1RJmR93MQp938nnPhbpHELa
|
22
|
+
RVfLuPew9y692PcZhYupGoIOL6VLZMOGpNJHuIaE922K4mSXHRgrHCHDDLOUhhEf
|
23
|
+
98bBxW6fHQVR9vBRSLej30BHMbMCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUu1CMcKa3y7w94xOkbcHu0K1W2H4wJgYDVR0RBB8w
|
25
25
|
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAbMLLOjxf
|
27
|
+
iJ2sMYS9Ha6mCF2UbZWjtrcMniJQw2LipLnxtR95lICHLn+P2K0Kg/0AnZYOSGIe
|
28
|
+
rTMyZKt7kW+zBJYQRBPE7usLULwGj72JRE/aySgQHoF3uCIHb/UDV8XXwXkwlSoo
|
29
|
+
1R5AgQLaWKY3zFXUuvxbb/flJwvHF1cbHJvc7kZXeILOnbP0XXiiuulgFYZlcZI2
|
30
|
+
MAC+xoMLQY6qQSE/BmK8vBaaWbZ6tVZpk2tx969f/2lZYfwHKmguQKE3lmarRDX6
|
31
|
+
uOVdk9PsRKwYmaspqeSKWj4fpSd1mCtTjPlLbGQC/8sULVs7AlYVp2pAKbkXkbTn
|
32
|
+
EkYZt+RIxgYhhw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-
|
34
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: websocket-eventmachine-server
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
40
43
|
- - ">="
|
41
44
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
45
|
+
version: 1.0.1
|
43
46
|
type: :runtime
|
44
47
|
prerelease: false
|
45
48
|
version_requirements: !ruby/object:Gem::Requirement
|
46
49
|
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.0'
|
47
53
|
- - ">="
|
48
54
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
55
|
+
version: 1.0.1
|
50
56
|
- !ruby/object:Gem::Dependency
|
51
57
|
name: websocket-eventmachine-client
|
52
58
|
requirement: !ruby/object:Gem::Requirement
|
53
59
|
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.0'
|
54
63
|
- - ">="
|
55
64
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
65
|
+
version: 1.0.1
|
57
66
|
type: :runtime
|
58
67
|
prerelease: false
|
59
68
|
version_requirements: !ruby/object:Gem::Requirement
|
60
69
|
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.0'
|
61
73
|
- - ">="
|
62
74
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
75
|
+
version: 1.0.1
|
64
76
|
- !ruby/object:Gem::Dependency
|
65
77
|
name: xml-registry
|
66
78
|
requirement: !ruby/object:Gem::Requirement
|
67
79
|
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
68
83
|
- - ">="
|
69
84
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
85
|
+
version: 0.2.3
|
71
86
|
type: :runtime
|
72
87
|
prerelease: false
|
73
88
|
version_requirements: !ruby/object:Gem::Requirement
|
74
89
|
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0.2'
|
75
93
|
- - ">="
|
76
94
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
95
|
+
version: 0.2.3
|
78
96
|
description:
|
79
97
|
email: james@r0bertson.co.uk
|
80
98
|
executables: []
|
@@ -94,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
112
|
requirements:
|
95
113
|
- - ">="
|
96
114
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
115
|
+
version: 2.1.0
|
98
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
117
|
requirements:
|
100
118
|
- - ">="
|
@@ -107,3 +125,4 @@ signing_key:
|
|
107
125
|
specification_version: 4
|
108
126
|
summary: simplepubsub
|
109
127
|
test_files: []
|
128
|
+
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|