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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e2bb403ba535ddc3097815566d5d19936ea86e1
4
- data.tar.gz: 4919d72301e1b6bd5afb05742a28e897cbd0b194
3
+ metadata.gz: 1f44862fbd5f5bbedf3b8d9c2b108cec95fa6076
4
+ data.tar.gz: bb98ceee51189f93220dfa68b3b4b473c0982d23
5
5
  SHA512:
6
- metadata.gz: 830e2d740aec3fe17a899f1623f0a7a4844ac9fe69348df0b3ce335f4a27decf0dea5af19039259da9dc3875061a1d6017aec676bda51003eab6d6c006cb4421
7
- data.tar.gz: 558c3876da55ee779fea5d336f984fff2163b8420dae64a95b4680950eb9931db5ce6b551a2464250fe01987b0af55bceadfa8fb664c059f7efd46fbc78a3a30
6
+ metadata.gz: 90a4cfbc1b5db576860cf66e44023a9f31dcd1f3834ee6dcdec73bd0ae6c852443ac544d5c1f2186f173d5b5e62767066ff0a46fb8fc7ac278c0b5f1d82f4d3f
7
+ data.tar.gz: 7c4ada019199d0bf1b64179d1232ee03ae0dbe403955e3cf657b8b2c7bf122cea5125fbaef8993f8f56b9a6f52ff8c43f065a66ac0bc8abdef025f5a5145f84e
@@ -7,13 +7,14 @@ class Subscriber
7
7
  include Celluloid::Logger
8
8
 
9
9
  def initialize
10
- CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
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.publish('test_channel', 'data' => 'my_message') # the message needs to be a Hash
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
 
@@ -17,7 +17,7 @@ module CelluloidPubsub
17
17
  # minor release version
18
18
  MINOR = 0
19
19
  # tiny release version
20
- TINY = 9
20
+ TINY = 10
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
@@ -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.9
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-16 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid