class Slack::RealTime::Concurrency::Celluloid::Socket
Constants
- BLOCK_SIZE
Attributes
socket[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Slack::RealTime::Socket::new
# File lib/slack/real_time/concurrency/celluloid.rb, line 23 def initialize(*args) super @driver = build_driver end
Public Instance Methods
connect!()
click to toggle source
@yieldparam [WebSocket::Driver] driver
Calls superclass method
Slack::RealTime::Socket#connect!
# File lib/slack/real_time/concurrency/celluloid.rb, line 29 def connect! super driver.start future.run_loop end
connected?()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 53 def connected? !@connected.nil? end
read()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 42 def read buffer = socket.readpartial(BLOCK_SIZE) driver.parse buffer end
run_loop()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 36 def run_loop loop { read } if socket rescue EOFError # connection closed end
start_async() { |self| ... }
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 47 def start_async future = yield self if block_given? Actor.new(future) end
Protected Instance Methods
build_driver()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 81 def build_driver ::WebSocket::Driver.client(self) end
build_socket()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 71 def build_socket socket = TCPSocket.new(addr, port) socket = SSLSocket.new(socket, build_ssl_context) if secure? socket end
build_ssl_context()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 77 def build_ssl_context OpenSSL::SSL::SSLContext.new(:TLSv1_2_client) end
connect()
click to toggle source
# File lib/slack/real_time/concurrency/celluloid.rb, line 85 def connect @socket = build_socket @connected = @socket.connect end