Class: Slack::RealTime::Socket
- Inherits:
-
Object
- Object
- Slack::RealTime::Socket
- Defined in:
- lib/slack/real_time/socket.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #connect! {|@ws| ... } ⇒ Object
- #connected? ⇒ Boolean
- #disconnect! ⇒ Object
-
#initialize(url, options = {}) ⇒ Socket
constructor
A new instance of Socket.
- #send_data(data) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Socket
Returns a new instance of Socket.
7 8 9 10 |
# File 'lib/slack/real_time/socket.rb', line 7 def initialize(url, = {}) @url = url @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/slack/real_time/socket.rb', line 5 def @options end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/slack/real_time/socket.rb', line 4 def url @url end |
Instance Method Details
#connect! {|@ws| ... } ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/slack/real_time/socket.rb', line 16 def connect!(&_block) return if connected? @ws = Faye::WebSocket::Client.new(url, nil, ) @ws.on :close do |event| close(event) end yield @ws if block_given? end |
#connected? ⇒ Boolean
32 33 34 |
# File 'lib/slack/real_time/socket.rb', line 32 def connected? !@ws.nil? end |
#disconnect! ⇒ Object
28 29 30 |
# File 'lib/slack/real_time/socket.rb', line 28 def disconnect! @ws.close if @ws end |
#send_data(data) ⇒ Object
12 13 14 |
# File 'lib/slack/real_time/socket.rb', line 12 def send_data(data) @ws.send(data) if @ws end |