sps_duplex 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +5 -0
- data.tar.gz.sig +4 -0
- data/lib/sps_duplex.rb +58 -0
- metadata +106 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9160f1306413a8e31330ef598cdaf8c6c099a1cb
|
4
|
+
data.tar.gz: 7516af80a6f31d2b4dbdbbdd6418191aa2717f3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 037f4a5ec8175b3cae590214fcc8482800a59b271548a75c7c90a6ad669de37649d6bba98fa9675650963040b3c7d111bc72174ea6ac117c05e1087f1d3d7552
|
7
|
+
data.tar.gz: 30c54202fe73e33d75f1caf54f9c9c82af7550f4437f62ce210564205934f354867992b8e28e171a00856c83d6c1f7e55101ef041c13ac27a722b82c14907734
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
data/lib/sps_duplex.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: sps_duplex.rb
|
4
|
+
|
5
|
+
require 'sps-pub'
|
6
|
+
require 'sps-sub'
|
7
|
+
|
8
|
+
|
9
|
+
class SPSDuplex
|
10
|
+
|
11
|
+
def initialize(host: 'localhost', port: '55000', topic: 'chan1',
|
12
|
+
sub_topic: 'node1', pub_topic: 'node2')
|
13
|
+
|
14
|
+
|
15
|
+
sps = SPSSub.new host: host, port: port, callback: self
|
16
|
+
puts 'connecting ...'
|
17
|
+
sleep 1 # give it a second to connect
|
18
|
+
|
19
|
+
topic_path = [topic]
|
20
|
+
Thread.new { sps.subscribe topic: (topic_path + [sub_topic]).join('/') }
|
21
|
+
|
22
|
+
@pub = SPSPub.new address: host, port: port
|
23
|
+
|
24
|
+
topic_path << pub_topic
|
25
|
+
@topic = topic_path.join('/')
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def send(msg)
|
30
|
+
|
31
|
+
@pub.notice ("%s: %s" % [@topic, msg])
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# used by the callback routine
|
36
|
+
#
|
37
|
+
def ontopic(topic, msg)
|
38
|
+
|
39
|
+
a = topic.split('/')
|
40
|
+
sender = a.pop
|
41
|
+
onincoming(sender, msg)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def onincoming(sender, msg)
|
46
|
+
|
47
|
+
puts "%s: %s" % [sender, msg]
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
if __FILE__ == $0 then
|
54
|
+
|
55
|
+
channel = SPSDuplex.new port: 55000
|
56
|
+
channel.send 'hello'
|
57
|
+
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sps_duplex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTI5MTkxNzA0WhcN
|
15
|
+
MTkwMTI5MTkxNzA0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC4VM4E
|
17
|
+
TP37JMEgkaJMsQ6OpdmaWsgbeAQw0RrCs1lsiV1q6hPV63oXX9HzDa7/WRpO/l1T
|
18
|
+
GkhxFUu10Li2sQYRplAXd55nqevjXgc5+xEWWDRAvGGXkgJoaJsRl/EueQX/NPU6
|
19
|
+
KhbkNoijVZrBqN976+b0iKMbXVO/xqaKYgw6xrWBhitgLdR2Gqqe7vq/E6K12faS
|
20
|
+
LQ5sZIfqo4V/RqLXibqIjl3YXP2m3wB6ZnDkQdRU4nSnCrTe5bSUe6feaibAzH/z
|
21
|
+
kNaU62SWByypKPG8oB2RD8RHkG7fgThVrsfjLGmWKXO//syDsa2XnCOm6ZjMNv6u
|
22
|
+
Vr0L0VUBkvNF4az3AgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
23
|
+
HQYDVR0OBBYEFJavGfyDqiWes/oR0zYWJIbN+TlhMCYGA1UdEQQfMB2BG2dlbW1h
|
24
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
|
25
|
+
ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBABhmAjKxsQ1MZqirvXWD
|
26
|
+
EIf7ikrC8tlNBVNTigKCl6Y7Ay0QpI0JfV7Rxt5KO23fbIyPEZvx46419w7URshf
|
27
|
+
DT8O4fupKaeRrQHIjrqIKAwovwMnHA6vmW4l8La+dB7bPXBnNZZkhBpZ45i2fYEK
|
28
|
+
Gc4qhxHi7Uhth33XvvbFfLoO2VdwBhGemNAftnSKTsxBwRgcZ5kC4nDV1DXyLHbB
|
29
|
+
2WXRqkkcQ4aNSN9I+OC7lzQkoSWCBfetAgQhQBLZll4+zmLJ8caRsFGyl58poz8m
|
30
|
+
LIcNOT9VT9Tnfr0APnMF60XnS4QMvFVUQ1NQPvsgq9tRCSIwc6fdOaYPqcs4tnSe
|
31
|
+
m4s=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sps-sub
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.3'
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.3.6
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - "~>"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0.3'
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sps-pub
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.5'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.5.5
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.5'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.5.5
|
75
|
+
description:
|
76
|
+
email: james@jamesrobertson.eu
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- lib/sps_duplex.rb
|
82
|
+
homepage: https://github.com/jrobertson/sps_duplex
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.6.13
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: A gem to allow 2 way communication using a SimplePubSub broker.
|
106
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|