class CTI::MainOut
Public Class Methods
new(io, session)
click to toggle source
# File CTI/Session.rb 473 def initialize(io, session) 474 @io = io 475 @session = session 476 end
Public Instance Methods
close()
click to toggle source
# File CTI/Session.rb 504 def close 505 @io.req_eof 506 while @session.build_next 507 end 508 end
write(str)
click to toggle source
# File CTI/Session.rb 478 def write(str) 479 e = str.encoding; 480 str.force_encoding(Encoding::ASCII_8BIT) 481 bio = @io.respond_to?('write_nonblock') 482 while str.bytesize > 0 483 data = str.slice!(0, CTIP2::CTI_BUFFER_SIZE) 484 packet = [data.bytesize + 1, CTIP2::REQ_DATA].pack('NC') + data 485 while packet.bytesize > 0 486 rs, ws = IO::select([@io], [@io]) 487 if packet.bytesize > 0 && ws[0] 488 if bio 489 len = @io.write_nonblock(packet) 490 @io.nonblock = false 491 else 492 len = @io.write(packet) 493 end 494 packet.slice!(0, len) 495 end 496 if rs[0] 497 @session.build_next 498 end 499 end 500 end 501 str.force_encoding(e) 502 end