sps-sub 0.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 +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/lib/sps-sub.rb +63 -0
- metadata +87 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4bee6db849030c291086d5c12cae543749935ddb
|
4
|
+
data.tar.gz: 50f01815400adaf57f61df438f34142fe15aa1d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f20e7b1a9d03f7cdb2c44f95f7c1e6993d770c3abec45eacb42ee31ddbcdafe36b41452e88eae4353399545224d475decf4f3424346bf5f2153f9661876d699
|
7
|
+
data.tar.gz: d01f6a9845f3c5bf7f7c656ff19d98c964cfff6cf432bfcb8800823f245f51e4eb90d6e9ae7fd13bbf95ae24a408d5baad07428777d3d58ddd61967545c29b84
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/lib/sps-sub.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: sps-sub.rb
|
4
|
+
|
5
|
+
require 'websocket-eventmachine-client'
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
class SPSSub
|
10
|
+
|
11
|
+
def initialize(port: '59000', host: nil, address: nil)
|
12
|
+
|
13
|
+
@host = host || address || 'localhost'
|
14
|
+
@port = port.to_s
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def subscribe(topic: nil)
|
19
|
+
|
20
|
+
host, port = @host, @port
|
21
|
+
|
22
|
+
EM.run do
|
23
|
+
|
24
|
+
address = host + ':' + port
|
25
|
+
|
26
|
+
ws = WebSocket::EventMachine::Client.connect(:uri => 'ws://' + address)
|
27
|
+
|
28
|
+
ws.onopen do
|
29
|
+
puts "Connected"
|
30
|
+
end
|
31
|
+
|
32
|
+
ws.onmessage do |msg, type|
|
33
|
+
onmessage msg
|
34
|
+
end
|
35
|
+
|
36
|
+
ws.onclose do
|
37
|
+
puts "Disconnected"
|
38
|
+
end
|
39
|
+
|
40
|
+
EventMachine.next_tick do
|
41
|
+
ws.send 'subscribe to topic: ' + topic
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def onmessage(msg)
|
48
|
+
puts "Received message: #{msg}"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
if __FILE__ == $0 then
|
54
|
+
|
55
|
+
sps = SPSSub.new port: 8080
|
56
|
+
|
57
|
+
def sps.onmessage(msg)
|
58
|
+
puts "%s: %s" % [Time.now.to_s, msg.inspect]
|
59
|
+
end
|
60
|
+
|
61
|
+
sps.subscribe topic: 'test'
|
62
|
+
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sps-sub
|
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
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MDUxNjA5NDEzNFoXDTE2MDUxNTA5NDEzNFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZ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M
|
32
|
+
B2N6m1GaxGXUJQ==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: websocket-eventmachine-client
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.1.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.0'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.0
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/sps-sub.rb
|
63
|
+
homepage: https://github.com/jrobertson/sps-sub
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.6
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Subscribes to a SimplePubsub (SPS) broker
|
87
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|