Class: UV::OutboundConnection

Inherits:
TcpConnection show all
Defined in:
lib/uv-rays/connection.rb

Direct Known Subclasses

HttpEndpoint::Connection

Instance Attribute Summary

Attributes inherited from Connection

#using_tls

Instance Method Summary collapse

Methods inherited from TcpConnection

#close_connection, #keepalive, #on_close, #on_connect, #stream_file, #write

Methods inherited from Connection

#close_connection, #on_read, #pause, #paused?, #post_init, #resume

Constructor Details

#initialize(server, port) ⇒ OutboundConnection

Returns a new instance of OutboundConnection.



129
130
131
132
133
134
135
136
137
138
# File 'lib/uv-rays/connection.rb', line 129

def initialize(server, port)
    super()

    @reactor = reactor
    @server = server
    @port = port
    @transport = @reactor.tcp

    ::UV.try_connect(@transport, self, @server, @port)
end

Instance Method Details

#reconnect(server = nil, port = nil) ⇒ Object



150
151
152
153
154
155
156
157
158
# File 'lib/uv-rays/connection.rb', line 150

def reconnect(server = nil, port = nil)
    @reactor = reactor

    @transport = @reactor.tcp
    @server = server || @server
    @port = port || @port

    ::UV.try_connect(@transport, self, @server, @port)
end

#use_tls(args = {}) ⇒ Object



140
141
142
143
144
145
146
147
148
# File 'lib/uv-rays/connection.rb', line 140

def use_tls(args = {})
    args.delete(:server)

    if @transport.connected
        @transport.start_tls(args)
    else
        @using_tls = args
    end
end