Sha256: e05b38d641124234bc941bd3852e1f277ce6336e90b37eb248d50d793ddd87b3

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

require 'celluloid'
require 'set'
require 'forwardable'
require 'rlyeh/logger'

module Rlyeh
  class Session
    include Celluloid
    include Rlyeh::Logger
    extend Forwardable

    attr_reader :id, :connections
    def_delegators :@connections, :include?, :empty?

    def initialize(id)
      @id = id
      @connections = Set.new
      debug "Session started: #{@id}"
    end

    def close
      debug "Session closed: #{@id}"
    end

    def attach(connection)
      connection.attach self
      @connections.add connection
    end

    def detach(connection)
      @connections.delete connection
      connection.detach self
    end

    def send_data(data)
      @connections.each do |connection|
        connection.send_data data, false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rlyeh-0.1.1 lib/rlyeh/session.rb