Sha256: 3169b115d978e0eed1dc85d64bdc7521db4aacee45f4c574e037137376bbd591

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

# Copyright 2009 emonti at matasano.com 
# See README.rdoc for license information
#

# Experimental!!!

require 'eventmachine'
require 'rbkb/plug'
require 'rbkb'

module Plug
  class PeerStub
    attr_reader :owner

    def initialize(owner)
      @owner = owner
    end

    def [](junk)
      @owner
    end

    def []=(junk)
      [@owner]
    end

    def peers
      nil
    end
  end

  module UnixDomain
    attr_accessor :mute, :peers

    def initialize
      @peers = PeerStub.new(self)
    end

    def name
      "a domain socket"
    end

    def receive_data(dat)
      puts "Got:", dat.hexdump
    end

    def say(dat, sender)
      UI.dump(sender.name, self.name, dat)
      send_data(dat)
    end
  end
end


if $0 == __FILE__
  Plug::UI::LOGCFG[:verbose] = true

  b_addr = Plug::Blit::DEFAULT_IPADDR
  b_port = Plug::Blit::DEFAULT_PORT
  unless (sock=ARGV.shift and ARGV.shift.nil?)
    STDERR.puts "usage: #{File.basename $0} unix_socket"
    exit 1
  end


  EventMachine.run {
    s = EventMachine.connect_unix_domain(sock, Plug::UnixDomain)
    Plug::UI::verbose("** UNIX-DOMAIN-#{sock.inspect} Started")

    # connect a blit channel:
    EventMachine.start_server(b_addr, b_port, Plug::Blit, :TCP, s)
    Plug::UI::verbose("** BLITSRV-#{b_addr}:#{b_port}(TCP) Started")
  }

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
emonti-rbkb-0.6.6 lib/rbkb/plug/unix_domain.rb
emonti-rbkb-0.6.7 lib/rbkb/plug/unix_domain.rb
emonti-rbkb-0.6.8 lib/rbkb/plug/unix_domain.rb
emonti-rbkb-0.6.9.1 lib/rbkb/plug/unix_domain.rb
emonti-rbkb-0.6.9 lib/rbkb/plug/unix_domain.rb
rbkb-0.7.2 lib/rbkb/plug/unix_domain.rb
rbkb-0.7.1 lib/rbkb/plug/unix_domain.rb
rbkb-0.7.0 lib/rbkb/plug/unix_domain.rb
rbkb-0.6.12 lib/rbkb/plug/unix_domain.rb
rbkb-0.6.11 lib/rbkb/plug/unix_domain.rb
rbkb-0.6.10 lib/rbkb/plug/unix_domain.rb