Sha256: d45f4e2240b78b8942008e79e86137f88c08da235a819b32385a637b8ff54ebc
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
module Isomorfeus module Transport class ServerSocketProcessor include Isomorfeus::Transport::ServerProcessor def on_message(client, data) if Isomorfeus.development? write_lock = Isomorfeus.zeitwerk_lock.try_write_lock if write_lock Isomorfeus.zeitwerk.reload Isomorfeus.zeitwerk_lock.release_write_lock end Isomorfeus.zeitwerk_lock.acquire_read_lock end request_hash = Oj.load(data, mode: :strict) handler_instance_cache = {} response_agent_array = [] Thread.current[:isomorfeus_user] = user(client) Thread.current[:isomorfeus_pub_sub_client] = client process_request(request_hash, handler_instance_cache, response_agent_array) handler_instance_cache.each_value do |handler| handler.resolve if handler.resolving? end result = {} response_agent_array.each do |response_agent| result.deep_merge!(response_agent.result) end client.write Oj.dump(result, mode: :strict) unless result.empty? ensure Thread.current[:isomorfeus_user] = nil Thread.current[:isomorfeus_pub_sub_client] = nil Isomorfeus.zeitwerk_lock.release_read_lock if Isomorfeus.development? end def on_close(client) # nothing for now end def on_open(client) # nothing for now end def on_shutdown(client) # nothing for now end def user(client) current_user = client.instance_variable_get(:@isomorfeus_user) return current_user if current_user Anonymous.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
isomorfeus-transport-1.0.0.zeta25 | lib/isomorfeus/transport/server_socket_processor.rb |
isomorfeus-transport-1.0.0.zeta24 | lib/isomorfeus/transport/server_socket_processor.rb |