lib/adhearsion/voip/freeswitch/basic_connection_manager.rb in adhearsion-0.8.3 vs lib/adhearsion/voip/freeswitch/basic_connection_manager.rb in adhearsion-0.8.4

- old
+ new

@@ -1,24 +1,24 @@ module Adhearsion module VoIP module FreeSwitch - + class BasicConnectionManager def initialize(io) @io = io end - + # The send-command operator def <<(str) @io.write str + "\n\n" end - + def get_header separate_pairs get_raw_header end - + def get_raw_header (returning [] do |lines| until line = @io.gets and line.chomp.empty? lines << line.chomp end @@ -29,20 +29,20 @@ header = get_raw_header length = header.first[/\d+$/].to_i # puts "Reading an event of #{length} bytes" separate_pairs @io.read(length) end - + def separate_pairs(lines) lines.inject({}) do |h,line| returning h do |hash| k,v = line.split(/\s*:\s*/) hash[k] = URI.unescape(v).strip if k && v end end end - + end - + end end end