celluloid_pubsub 0.0.9 → 0.0.10
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
- data/examples/simple_test.rb +17 -4
- data/lib/celluloid_pubsub/version.rb +1 -1
- data/lib/celluloid_pubsub/web_server.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f44862fbd5f5bbedf3b8d9c2b108cec95fa6076
|
4
|
+
data.tar.gz: bb98ceee51189f93220dfa68b3b4b473c0982d23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90a4cfbc1b5db576860cf66e44023a9f31dcd1f3834ee6dcdec73bd0ae6c852443ac544d5c1f2186f173d5b5e62767066ff0a46fb8fc7ac278c0b5f1d82f4d3f
|
7
|
+
data.tar.gz: 7c4ada019199d0bf1b64179d1232ee03ae0dbe403955e3cf657b8b2c7bf122cea5125fbaef8993f8f56b9a6f52ff8c43f065a66ac0bc8abdef025f5a5145f84e
|
data/examples/simple_test.rb
CHANGED
@@ -7,13 +7,14 @@ class Subscriber
|
|
7
7
|
include Celluloid::Logger
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
@client = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
|
11
11
|
ws.subscribe('test_channel') # this will execute after the connection is opened
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def on_message(message)
|
16
|
-
puts "got #{message.inspect}"
|
16
|
+
puts "subscriber got #{message.inspect}"
|
17
|
+
@client.publish('test_channel2', 'data' => 'my_message') # the message needs to be a Hash
|
17
18
|
end
|
18
19
|
|
19
20
|
def on_close(code, reason)
|
@@ -28,9 +29,21 @@ class Publisher
|
|
28
29
|
include Celluloid::Logger
|
29
30
|
|
30
31
|
def initialize
|
31
|
-
CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
|
32
|
-
ws.
|
32
|
+
@client = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
|
33
|
+
ws.subscribe('test_channel2') # this will execute after the connection is opened
|
33
34
|
end
|
35
|
+
@client.publish('test_channel', 'data' => 'my_message') # the message needs to be a Hash
|
36
|
+
@client.publish('test_channel', 'data' => 'my_message')
|
37
|
+
@client.publish('test_channel', 'data' => 'my_message')
|
38
|
+
end
|
39
|
+
|
40
|
+
def on_message(message)
|
41
|
+
puts " publisher got #{message.inspect}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def on_close(code, reason)
|
45
|
+
puts "websocket connection closed: #{code.inspect}, #{reason.inspect}"
|
46
|
+
terminate
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
@@ -110,7 +110,7 @@ module CelluloidPubsub
|
|
110
110
|
#
|
111
111
|
# @api public
|
112
112
|
def publish_event(current_topic, message)
|
113
|
-
return if current_topic.blank? || message.blank?
|
113
|
+
return if current_topic.blank? || message.blank? || @subscribers[current_topic].blank?
|
114
114
|
@subscribers[current_topic].each do |hash|
|
115
115
|
hash[:reactor].websocket << message
|
116
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|