Method: Jabber::Connection#connect

Defined in:
lib/vendor/xmpp4r/lib/xmpp4r/connection.rb

#connect(host, port) ⇒ Object

Connect to the Jabber server through a TCP Socket, start the Jabber parser, invoke to accept_features to wait for TLS, start the keep-alive thread



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vendor/xmpp4r/lib/xmpp4r/connection.rb', line 59

def connect(host, port)
  @host = host
  @port = port
  # Reset is_tls?, so that it works when reconnecting
  @tls = false

  Jabber::debuglog("CONNECTING:\n#{@host}:#{@port}")
  @socket = TCPSocket.new(@host, @port)

  # We want to use the old and deprecated SSL protocol (usually on port 5223)
  if @use_ssl
    ssl = OpenSSL::SSL::SSLSocket.new(@socket)
    ssl.connect # start SSL session
    ssl.sync_close = true
    Jabber::debuglog("SSL connection established.")
    @socket = ssl
  end

  start

  accept_features

  @keepaliveThread = Thread.new do
    Thread.current.abort_on_exception = true
    keepalive_loop
  end
end