Sha256: 8d2b6b7cbc8db7436cb7e0d450960fc438c56b7c732a243f3ebc870bb8a9f8ed
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
require 'faye/websocket' require 'eventmachine' module Slack module RealTime module Concurrency module Eventmachine class Client < Faye::WebSocket::Client attr_reader :logger protected :logger def initialize(url, protocols = nil, options = {}) @logger = options.delete(:logger) || Slack::RealTime::Config.logger || Slack::Config.logger super end def parse(data) logger.debug("#{self.class}##{__method__}") { data } super data end def write(data) logger.debug("#{self.class}##{__method__}") { data } super data end end class Socket < Slack::RealTime::Socket def start_async(client) @thread = ensure_reactor_running client.run_loop @thread end def close super EventMachine.stop if @thread @thread = nil end def send_data(message) logger.debug("#{self.class}##{__method__}") { message } driver.send(message) end protected # @return [Thread] def ensure_reactor_running return if EventMachine.reactor_running? reactor = Thread.new { EventMachine.run } Thread.pass until EventMachine.reactor_running? reactor end def connect @driver = Client.new(url, nil, options.merge(logger: logger)) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-client-0.13.1 | lib/slack/real_time/concurrency/eventmachine.rb |
slack-ruby-client-0.13.0 | lib/slack/real_time/concurrency/eventmachine.rb |