sps_chat 0.2.1 → 0.2.2
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sps_chat.rb +6 -27
- metadata +2 -2
- 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: a6478683020ca1ea0046516cd4aa64c493205038
|
4
|
+
data.tar.gz: 57680e445c4c8b1419041e864dee0d0a4c8aad5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7857ec94ddafdfe7248181ef55218bc189239e62c81b38280b47b2dfbd74c2f7fc2c1df0cbaa03207ab4f2a830d2fd7ff1b15d2b9aa1fa9aa4ede32d5caa1bf4
|
7
|
+
data.tar.gz: cc1174dba940918ec2150863ebe78dd881ddd0b938b25e4f969ad1ae5330d6ef92dc5055c08ac658fdc85545844e4868d079aa2e6f0508ee5ffd7910f0a72be9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/sps_chat.rb
CHANGED
@@ -2,36 +2,17 @@
|
|
2
2
|
|
3
3
|
# file: sps_chat.rb
|
4
4
|
|
5
|
-
require '
|
6
|
-
require 'sps-sub'
|
5
|
+
require 'sps_duplex'
|
7
6
|
|
8
7
|
|
9
|
-
class SPSChat
|
8
|
+
class SPSChat < SPSDuplex
|
10
9
|
|
11
10
|
def initialize(host: 'localhost', port: '8080', \
|
12
11
|
userid: 'user' + (0..1000).to_a.sample.to_s, room: '')
|
13
12
|
|
14
|
-
@userid = userid
|
15
|
-
|
16
|
-
|
17
|
-
puts 'connecting ...'
|
18
|
-
sleep 1 # give it a second to connect
|
19
|
-
|
20
|
-
topic = ['chat']
|
21
|
-
topic << room if room.length > 0
|
22
|
-
|
23
|
-
Thread.new { sps.subscribe topic: (topic + ['#']).join('/') }
|
24
|
-
|
25
|
-
@pub = SPSPub.new address: host, port: port
|
26
|
-
|
27
|
-
topic << userid
|
28
|
-
@topic = topic.join('/')
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def send(msg)
|
33
|
-
|
34
|
-
@pub.notice ("%s: %s" % [@topic, msg])
|
13
|
+
@userid = userid
|
14
|
+
super(host: host, port: port, topic: 'chat',
|
15
|
+
sub_topic: '#', pub_topic: userid)
|
35
16
|
|
36
17
|
end
|
37
18
|
|
@@ -40,9 +21,7 @@ class SPSChat
|
|
40
21
|
@pub.notice ("%s/typing: %s" % [@topic, c])
|
41
22
|
|
42
23
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
|
46
25
|
# used by the callback routine
|
47
26
|
#
|
48
27
|
def ontopic(topic, msg)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sps_chat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
s9dItOR/wNvg6SaW6COsX0wSHRUDvZm00WV5IykZk86V0G0jIVdbQxW6CMs/LzbZ
|
31
31
|
y7I=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-02-
|
33
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sps_duplex
|
metadata.gz.sig
CHANGED
Binary file
|