magicbus 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/magicbus/subscriber.rb +4 -11
- data/lib/magicbus/version.rb +1 -1
- metadata +1 -1
data/lib/magicbus/subscriber.rb
CHANGED
@@ -24,19 +24,17 @@ class MagicBus::Subscriber
|
|
24
24
|
channel = channels[user_id]
|
25
25
|
exchange = channel.fanout('syme')
|
26
26
|
|
27
|
-
self.clients[user_id] ||= {}
|
28
|
-
|
29
27
|
client_id = SecureRandom.uuid
|
30
28
|
|
31
|
-
self.clients[user_id][client_id] = out
|
32
|
-
|
33
29
|
queue = channel.queue(client_id)
|
34
30
|
.bind(exchange).subscribe do |payload|
|
35
31
|
|
36
|
-
|
37
|
-
"data: #{payload}\n\n"
|
32
|
+
out << "data: #{payload}\n\n"
|
38
33
|
|
39
34
|
end
|
35
|
+
|
36
|
+
self.clients[user_id] ||= {}
|
37
|
+
self.clients[user_id][client_id] = queue
|
40
38
|
|
41
39
|
client_id
|
42
40
|
|
@@ -50,11 +48,6 @@ class MagicBus::Subscriber
|
|
50
48
|
self.clients[user_id][client_id] = nil
|
51
49
|
end
|
52
50
|
|
53
|
-
if self.clients[user_id].length == 0
|
54
|
-
self.channels[user_id].close
|
55
|
-
self.clients.unsubscribe(user_id)
|
56
|
-
end
|
57
|
-
|
58
51
|
end
|
59
52
|
|
60
53
|
end
|
data/lib/magicbus/version.rb
CHANGED