Sha256: 6d99b2803b11630d64812c0a02a70c7b8100239e6347d9629dc73c6e1316a430
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
module GameServer::Client def receive_request(request) find_controller(request.name).new(self, request).run rescue Exception => e log_exception e end def send_line(string) log "send_line #{string}\n" send_data(string + "\n") end def send_json(object) send_line object.to_json end def receive_data(data) @data ||= "" @data += data if data =~ /\000\n$/ all_data = @data @data = "" all_data.gsub!("\000",'').split(/\n/).each do |string| request = GameServer::RequestParser.new(string).parse receive_request(request) end end end def find_controller(name) "#{self.class.name}::#{name.to_s.camelize}Controller".constantize rescue NameError "#{self.class.name}::NilController".constantize end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
game-server-0.4.0 | lib/client.rb |