Sha256: 103be8deeaac575a0b5ff0ed067f339630dc2de1aced6cb1822fd7a9e96f9cc1
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require "xmpp4r/client" require "drb" module Saber class Server def self.start # register on_finished event. Retort::Service.call("system.method.set_key", "event.download.closed", "saber-download", "execute= /usr/bin/saber-drb_add, $d.get_hash=, $d.get_custom1=") s = Server.new s.start DRbServer.start(s) DRb.thread.join end attr_reader :client def initialize @client = Jabber::Client.new(Jabber::JID.new(Rc.server.xmpp.jid)) end def start client.connect Rc.server.xmpp.host, Rc.server.xmpp.port client.auth Rc.server.xmpp.password client.send Jabber::Presence.new Saber.ui.say ">> Connected to xmpp with #{Rc.server.xmpp.jid}" end def send(files) Saber.ui.say %~::send::\n #{files.join("\n")}\n\n~ client.send Jabber::Message.new(Rc.client.xmpp.jid, files.join("\n")) end end class DRbServer class << self def start(saber_server) DRbServer.new(saber_server).start end end attr_reader :saber_server # @params [Server] server def initialize(saber_server) @saber_server = saber_server end def start DRb.start_service Rc.drb_uri, self Saber.ui.say ">> DRbSever listening on #{Rc.drb_uri}" end # drb. add a complete torrent. def add(*names) Saber.ui.debug "::DRbServer add:: #{names.inspect}" files = build_files(*names) saber_server.send(files) end private # ["filea", "foo/filea", "foo/fileb"] def build_files(*names) Pa.ls2_r(*names, :base_dir => Rc.server.download, :file => true, :include => true) { |path| not Pa.directory?(path) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
saber-0.0.3 | lib/saber/server.rb |