Sha256: 6740cf83f1588b366194aa675ef8d3970603f318d26b142abe1e5b3cdc3c939b
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 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 thread = ensure_reactor_running yield self if block_given? thread 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.7.1 | lib/slack/real_time/concurrency/eventmachine.rb |
slack-ruby-client-0.7.0 | lib/slack/real_time/concurrency/eventmachine.rb |