summaryrefslogtreecommitdiff
path: root/scripts/socket.rb
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/socket.rb')
-rw-r--r--scripts/socket.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/scripts/socket.rb b/scripts/socket.rb
index 5e0b1725702..2a9f31dda51 100644
--- a/scripts/socket.rb
+++ b/scripts/socket.rb
@@ -4,7 +4,7 @@ require "json"
EM.run do
@channels = Hash.new
- @redis = EM::Hiredis.connect("unix:///Users/phil/Projects/gdk-ce/redis/redis.socket")
+ @redis = EM::Hiredis.connect("unix://#{File.expand_path('..')}/redis/redis.socket")
pubsub = @redis.pubsub
pubsub.subscribe "todos"
pubsub.on(:message) do |redis_channel, message|
@@ -15,11 +15,8 @@ EM.run do
}
if redis_channel == "todos"
- @channels.each do |key, channel|
- if channel[:user_id].to_i == message["user_id"]
- channel[:channel].push data.to_json
- end
- end
+ channel = @channels[message["user_id"].to_s]
+ channel[:channel].push data.to_json
end
end