sps_chat 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 +3 -0
- data/lib/sps_chat.rb +52 -0
- data.tar.gz.sig +1 -0
- metadata +108 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f61d63062e039d56ad994c289fa4ffd1211d87ae
|
4
|
+
data.tar.gz: 6276f68c82299e3888176a413b3ea8489df85da0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c18425b84d7aa4a3e2d8d01b8915bb7306cf706033d40cee03b863c992bc401327fababdcf7389874f807a591185a984970625077b268e7ad1a43fa662df8900
|
7
|
+
data.tar.gz: 6083fe2cc9e46f648e5e6f711fa5b1e64ba672813936aadcdbe67b3f091a2005031155fb453f5bb3b382ebdb4f748760e3c6e934297aac48e8d5aa2e9cb89af3
|
checksums.yaml.gz.sig
ADDED
data/lib/sps_chat.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: sps_chat.rb
|
4
|
+
|
5
|
+
require 'sps-pub'
|
6
|
+
require 'sps-sub'
|
7
|
+
|
8
|
+
|
9
|
+
class SPSChat
|
10
|
+
|
11
|
+
def initialize(host: 'localhost', port: '8080', \
|
12
|
+
userid: 'user' + (0..1000).to_a.sample.to_s)
|
13
|
+
|
14
|
+
@userid = userid
|
15
|
+
|
16
|
+
sps = SPSSub.new host: host, port: port, callback: self
|
17
|
+
puts 'connecting ...'
|
18
|
+
sleep 1 # give it a second to connect
|
19
|
+
|
20
|
+
Thread.new { sps.subscribe topic: 'chat/#' }
|
21
|
+
@pub = SPSPub.new address: host, port: port
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def send(msg)
|
26
|
+
|
27
|
+
@pub.notice ("chat/%s: %s" % [@userid, msg])
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# used by the callback routine
|
32
|
+
#
|
33
|
+
def ontopic(topic, msg)
|
34
|
+
|
35
|
+
sender = topic.split('/').last
|
36
|
+
return if sender == @userid
|
37
|
+
onincoming sender, msg
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def onincoming(sender, msg)
|
42
|
+
puts "%s: %s" % [sender, msg]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
if __FILE__ == $0 then
|
48
|
+
|
49
|
+
chat = SPSChat.new port: 8080
|
50
|
+
chat.send 'hello'
|
51
|
+
|
52
|
+
end
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�����w�0��+}����[O |cN&�eTo������V� �+��ȝ�������E��&���K[tP��va*h����
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sps_chat
|
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
|
+
8ixkARkWAmV1MB4XDTE1MDUxNjEzNTA1MFoXDTE2MDUxNTEzNTA1MFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
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ERTIFICATE-----
|
34
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sps-sub
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.2'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.2'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.2.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: sps-pub
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.4'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.4.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.4'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.4.0
|
76
|
+
description:
|
77
|
+
email: james@r0bertson.co.uk
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- lib/sps_chat.rb
|
83
|
+
homepage: https://github.com/jrobertson/sps_chat
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.6
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A simple chat client which sends and receives messages through the SimplePubSub
|
107
|
+
broker
|
108
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|