class UV::TcpConnection
Public Instance Methods
close_connection(after_writing = false)
click to toggle source
# File lib/uv-rays/connection.rb, line 73 def close_connection(after_writing = false) if after_writing @transport.shutdown else @transport.close end end
keepalive(raw_time)
click to toggle source
# File lib/uv-rays/connection.rb, line 90 def keepalive(raw_time) time = raw_time.to_i if time.to_i <= 0 @transport.disable_keepalive else @transport.enable_keepalive(time) end end
on_close()
click to toggle source
# File lib/uv-rays/connection.rb, line 102 def on_close # user to define end
on_connect(transport)
click to toggle source
# File lib/uv-rays/connection.rb, line 99 def on_connect(transport) # user to define end
stream_file(filename, type = :raw)
click to toggle source
# File lib/uv-rays/connection.rb, line 81 def stream_file(filename, type = :raw) file = @reactor.file(filename, File::RDONLY) do # File is open and available for reading file.send_file(@transport, type, wait: :promise).finally do file.close end end return file end
write(data)
click to toggle source
# File lib/uv-rays/connection.rb, line 69 def write(data) @transport.write(data, wait: :promise) end