From ed87614309c0ecc7adfb551ac9d1734445b5f2ef Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 9 Oct 2012 01:03:49 -0400 Subject: [PATCH] corrected misspelled semaphore variable --- lib/jam_websockets/router.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/jam_websockets/router.rb b/lib/jam_websockets/router.rb index 15e184d14..ca18aa07b 100644 --- a/lib/jam_websockets/router.rb +++ b/lib/jam_websockets/router.rb @@ -83,27 +83,29 @@ module JamWebsockets begin routing_key = headers.envelope.routing_key user_id = routing_key["user.".length..-1] - @sempahore.synchronize do - @log.debug "USER ID = #{user_id}" + + @semaphore.synchronize do contexts = @user_context_lookup[user_id] - @log.debug "CONTEXT = #{contexts}" - unless contexts.nil? + if !contexts.nil? @log.debug "received user-directed message for user: #{user_id}" msg = Jampb::ClientMessage.parse(msg) + contexts.each do |context| EM.schedule do @log.debug "sending user message to #{context}" send_to_client(context.client, msg) end end + else + @log.debug "Context is null" end end rescue => e - @log.error "unhandled error in messaging to client" + @log.error e end end @@ -158,6 +160,7 @@ module JamWebsockets end rescue => e + @log.error "EXCEPTION = #{e}" @log.error "unhandled error in messaging to client" end end @@ -496,7 +499,7 @@ module JamWebsockets # create the friend_update message friend_update_msg = @message_factory.friend_update(user.id, online) - + # send the friend_update to each friend that has active connections user.friends.each do |friend| @log.debug "sending friend update message to #{friend}" @@ -617,6 +620,7 @@ module JamWebsockets session = access_music_session?(session_id, context.user) @log.debug "publishing to session #{session} from client_id #{client.client_id}" + # put it on the topic exchange for sessions @sessions_exchange.publish(client_msg.to_s, :routing_key => "session.#{session_id}", :properties => { :headers => { "client_id" => client.client_id } } ) end