Sha256: fd3a4cdb47cf90635b7c2b457083735787f2cdfb788247196c3873d87c4676b2

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

module Tribe
  module EM
    class Connection < Tribe::Actor
      # The Proxy class is what cleanly separates the EM connection and Tribe actor.
      def self.proxy_class
        return Tribe::EM::ActorProxy
      end

      private

      def initialize(options = {})
        @actor_proxy = options[:actor_proxy] || raise('You must provide an actor proxy.')

        super
      end

      def on_post_init(event)
      end

      def on_receive_data(event)
      end

      def on_unbind(event)
        enqueue(:shutdown)
      end

      def exception_handler(e)
        close
      end

      def shutdown_handler(event)
        close(true)
      end

      def write(data)
        @actor_proxy.write(data)
      end

      def close(after_writing = false)
        @actor_proxy.close(after_writing)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tribe_em-0.0.4 lib/tribe_em/connection.rb
tribe_em-0.0.3 lib/tribe_em/connection.rb