class CTI::MainOut

Public Instance Methods

close() click to toggle source
# File CTI/Session.rb, line 483
def close
  @io.req_eof
  while @session.build_next
  end
end
write(str) click to toggle source
# File CTI/Session.rb, line 460
def write(str)
  bio = @io.respond_to?('write_nonblock')
  while str.bytesize > 0
    data = str.slice!(0, CTIP2::CTI_BUFFER_SIZE)
    packet = [data.bytesize + 1, CTIP2::REQ_DATA].pack('NC') + data
    while packet.bytesize > 0
      rs, ws = IO::select([@io], [@io])
      if packet.bytesize > 0 && ws[0]
        if bio
          len = @io.write_nonblock(packet)
          @io.nonblock = false
        else
          len = @io.write(packet)
        end
        packet.slice!(0, len)
      end
      if rs[0]
        @session.build_next
      end
    end
  end
end

Public Class Methods

new(io, session) click to toggle source
# File CTI/Session.rb, line 455
def initialize(io, session)
  @io = io
  @session = session
end