sps_chat 0.1.0 → 0.1.1
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/lib/sps_chat.rb +14 -5
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: a0f48b2b5a5b99bdf677f2eafc88d6dd4d793817
|
4
|
+
data.tar.gz: 31ffa5fbc27e79ae4a53297a0f2ea49dfa33e555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9610ece62aa1068d0aa376a5f16b96f4144f49e6ed28f5c25bdca50a6044e8df3cf82d1fedf77d6da606edd49e36f0a486ebe9420679adaffafa80028452df
|
7
|
+
data.tar.gz: 96278bf1a54c4fd13eb4a86f5f41c61ecf90f0010950cb3ebb0580e5a6c917fc38f63931dea29ace35e0c85d9aea0c92b1228b185e553d41eb3d14d9aa96830b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sps_chat.rb
CHANGED
@@ -9,29 +9,36 @@ require 'sps-sub'
|
|
9
9
|
class SPSChat
|
10
10
|
|
11
11
|
def initialize(host: 'localhost', port: '8080', \
|
12
|
-
userid: 'user' + (0..1000).to_a.sample.to_s)
|
12
|
+
userid: 'user' + (0..1000).to_a.sample.to_s, room: '')
|
13
13
|
|
14
14
|
@userid = userid
|
15
15
|
|
16
16
|
sps = SPSSub.new host: host, port: port, callback: self
|
17
17
|
puts 'connecting ...'
|
18
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('/') }
|
19
24
|
|
20
|
-
Thread.new { sps.subscribe topic: 'chat/#' }
|
21
25
|
@pub = SPSPub.new address: host, port: port
|
26
|
+
|
27
|
+
topic << userid
|
28
|
+
@topic = topic.join('/')
|
22
29
|
|
23
30
|
end
|
24
31
|
|
25
32
|
def send(msg)
|
26
33
|
|
27
|
-
@pub.notice ("
|
34
|
+
@pub.notice ("%s: %s" % [@topic, msg])
|
28
35
|
|
29
36
|
end
|
30
37
|
|
31
38
|
# used by the callback routine
|
32
39
|
#
|
33
40
|
def ontopic(topic, msg)
|
34
|
-
|
41
|
+
|
35
42
|
sender = topic.split('/').last
|
36
43
|
return if sender == @userid
|
37
44
|
onincoming sender, msg
|
@@ -39,7 +46,9 @@ class SPSChat
|
|
39
46
|
end
|
40
47
|
|
41
48
|
def onincoming(sender, msg)
|
49
|
+
|
42
50
|
puts "%s: %s" % [sender, msg]
|
51
|
+
|
43
52
|
end
|
44
53
|
|
45
54
|
end
|
@@ -49,4 +58,4 @@ if __FILE__ == $0 then
|
|
49
58
|
chat = SPSChat.new port: 8080
|
50
59
|
chat.send 'hello'
|
51
60
|
|
52
|
-
end
|
61
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
lCVLcSK4BUROwuCG5CzgZgqMqPhEPu8W3rU4v6OD1HLgfu7iGHbIAs3gAGRCrJRD
|
32
32
|
VIkRGnNW0mJBFw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sps-sub
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.4.
|
103
|
+
rubygems_version: 2.4.8
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: A simple chat client which sends and receives messages through the SimplePubSub
|
metadata.gz.sig
CHANGED
Binary file
|