Class: RocketChat::Realtime::Connector
- Inherits:
-
Object
- Object
- RocketChat::Realtime::Connector
- Extended by:
- Forwardable
- Defined in:
- lib/rocket_chat/realtime/connector.rb
Overview
Socket manager
Instance Attribute Summary collapse
- #uri ⇒ Object readonly
Instance Method Summary collapse
-
#connect ⇒ Socket
(also: #socket)
Connect to server.
-
#initialize(url) ⇒ Connector
constructor
A new instance of Connector.
-
#port ⇒ Number
The port to connect.
-
#ssl? ⇒ Boolean
Check the SSL enabled.
Constructor Details
#initialize(url) ⇒ Connector
Returns a new instance of Connector.
23 24 25 |
# File 'lib/rocket_chat/realtime/connector.rb', line 23 def initialize(url) @uri = URI(url) end |
Instance Attribute Details
#uri ⇒ Object (readonly)
18 19 20 |
# File 'lib/rocket_chat/realtime/connector.rb', line 18 def uri @uri end |
Instance Method Details
#connect ⇒ Socket Also known as: socket
Connect to server
30 31 32 33 34 35 |
# File 'lib/rocket_chat/realtime/connector.rb', line 30 def connect return @socket if @socket return raw_socket unless ssl? ssl_socket end |
#port ⇒ Number
The port to connect
53 54 55 |
# File 'lib/rocket_chat/realtime/connector.rb', line 53 def port @uri.port || (ssl? ? 443 : 80) end |
#ssl? ⇒ Boolean
Check the SSL enabled
44 45 46 |
# File 'lib/rocket_chat/realtime/connector.rb', line 44 def ssl? @uri.scheme == 'wss' end |