simplepubsub 1.2.3 → 1.3.0
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 +2 -4
- data/lib/simplepubsub.rb +33 -3
- data.tar.gz.sig +0 -0
- metadata +31 -11
- 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: 3eebf1de4a72aeac11dcbcce95290b93b4a0fc2c
|
4
|
+
data.tar.gz: ddccd6756fbe4a6966df3a531122c503a38710bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1672e08f3427c42c85b4fdf5fe90db13c4fb054ee3792554e2de0927823f6f65f44648e43bea329063395d21084ee3f85587567ff6c7f0d5bcdd9797dce7ae1
|
7
|
+
data.tar.gz: d25884ca74467d9539a0187fd7db6e3f6229fb80a66b2a9f7a6068e98d5ebbccea84fce5adbe5d82fc3e1c16e3dbf2bcd99cc682521e4b6387273628250f876c
|
checksums.yaml.gz.sig
CHANGED
data/lib/simplepubsub.rb
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
# file: simplepubsub.rb
|
4
4
|
|
5
|
-
require
|
5
|
+
require "socket"
|
6
|
+
require 'sps-pub'
|
6
7
|
require 'xml-registry'
|
8
|
+
require 'websocket-eventmachine-server'
|
9
|
+
|
7
10
|
|
8
11
|
|
9
12
|
module SimplePubSub
|
@@ -11,7 +14,7 @@ module SimplePubSub
|
|
11
14
|
class Broker
|
12
15
|
|
13
16
|
|
14
|
-
def self.start(host: '0.0.0.0', port: 59000)
|
17
|
+
def self.start(host: '0.0.0.0', port: 59000, brokers: [])
|
15
18
|
|
16
19
|
|
17
20
|
EM.run do
|
@@ -26,7 +29,7 @@ module SimplePubSub
|
|
26
29
|
|
27
30
|
ws.onmessage do |msg, type|
|
28
31
|
|
29
|
-
msg = '' if not msg[0][
|
32
|
+
msg = '' if not msg[0][/[\w:]/]
|
30
33
|
a = msg.lstrip.split(/\s*:\s/,2)
|
31
34
|
|
32
35
|
def ws.subscriber?()
|
@@ -51,6 +54,33 @@ module SimplePubSub
|
|
51
54
|
|
52
55
|
current_topic, message = a
|
53
56
|
|
57
|
+
# is the message from another SPS broker?
|
58
|
+
|
59
|
+
if current_topic[0] == ':' then
|
60
|
+
|
61
|
+
# strip of the broker ID
|
62
|
+
current_topic.sub!(/:\w+\//,'')
|
63
|
+
|
64
|
+
elsif brokers.any?
|
65
|
+
|
66
|
+
brokers.each do |broker|
|
67
|
+
|
68
|
+
hostx, portx = broker.split(':',2)
|
69
|
+
portx ||= port
|
70
|
+
|
71
|
+
|
72
|
+
#puts 'address: ' + address.inspect
|
73
|
+
fqm = ":%s/%s: %s" % [Socket.gethostname, current_topic, message]
|
74
|
+
|
75
|
+
begin
|
76
|
+
SPSPub.notice fqm, host: hostx, port: portx
|
77
|
+
rescue
|
78
|
+
puts "warning couldn\'t send to %s:%s" % [hostx, portx]
|
79
|
+
end
|
80
|
+
#sleep 0.5
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
54
84
|
if not current_topic[0] == '/' and \
|
55
85
|
not current_topic =~ /[^a-zA-Z0-9\/_ ]$/ then
|
56
86
|
begin
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,48 +31,68 @@ cert_chain:
|
|
31
31
|
ESZzN7k2ND/MlTmSRterWKMTHfqcRezLMwpCUfuiwqBZjmitwfxLISVSb6KbdmAP
|
32
32
|
gwvxzXnCp16BVQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-
|
34
|
+
date: 2017-05-20 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: sps-pub
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '0.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.5.5
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '0.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.5.5
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: xml-registry
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
62
|
+
version: '0.5'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.
|
65
|
+
version: 0.5.3
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '0.
|
72
|
+
version: '0.5'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.5.3
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: websocket-eventmachine-server
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.0'
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.0.1
|
76
96
|
description:
|
77
97
|
email: james@jamesrobertson.eu
|
78
98
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|