Class: Slack::RealTime::Concurrency::Celluloid::Socket
- Extended by:
- Forwardable
- Includes:
- Celluloid::IO, Celluloid::Internals::Logger
- Defined in:
- lib/slack/real_time/concurrency/celluloid.rb
Defined Under Namespace
Classes: Actor
Constant Summary collapse
- BLOCK_SIZE =
4096
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Attributes inherited from Socket
Instance Method Summary collapse
- #connect! {|driver| ... } ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(*args) ⇒ Socket
constructor
A new instance of Socket.
- #read ⇒ Object
- #run_loop ⇒ Object
- #start_async ⇒ Object
Methods inherited from Socket
#close, #disconnect!, #send_data, #start_sync
Constructor Details
#initialize(*args) ⇒ Socket
Returns a new instance of Socket.
23 24 25 26 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 23 def initialize(*args) super @driver = build_driver end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
21 22 23 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 21 def socket @socket end |
Instance Method Details
#connect! {|driver| ... } ⇒ Object
29 30 31 32 33 34 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 29 def connect! super driver.start future.run_loop end |
#connected? ⇒ Boolean
53 54 55 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 53 def connected? !@connected.nil? end |
#read ⇒ Object
42 43 44 45 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 42 def read buffer = socket.readpartial(BLOCK_SIZE) driver.parse buffer end |
#run_loop ⇒ Object
36 37 38 39 40 |
# File 'lib/slack/real_time/concurrency/celluloid.rb', line 36 def run_loop loop { read } if socket rescue EOFError # connection closed end |