Sha256: c077d6488d0bf5ad7d2f95d6ff911a1ee8c6ba841710e8669efa5bfc99cfee67

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

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
          end) * "\n"
        end

        def next_event
          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

Version data entries

16 entries across 16 versions & 7 rubygems

Version Path
eric-adhearsion-0.7.999 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
eric-adhearsion-0.8.0 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
jicksta-adhearsion-0.7.999 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
jicksta-adhearsion-0.8.0 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
jicksta-adhearsion-0.8.2 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
jicksta-adhearsion-0.8.3 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
kenwiesner-adhearsioncw-0.8.3 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
mtrudel-adhearsion-0.8.3 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
sant0sk1-adhearsion-0.7.999 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
sevenscale-adhearsion-0.7.1000 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
sevenscale-adhearsion-0.7.1003 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
sevenscale-adhearsion-0.8.0 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
adhearsion-0.8.3 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
adhearsion-0.8.1 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
adhearsion-0.8.2 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
adhearsion-0.8.0 lib/adhearsion/voip/freeswitch/basic_connection_manager.rb