Sha256: 7d7b3a2516fd22006b1669e70cc9a8e3df646bb94afe5319c4d9358cc86901e8
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
require "tagen/xmpp4r" require "xmpp4r/client" require "drb" module Saber module AutoFetcher class Server def self.start s = Server.new DRbServer.start(s) s.start Thread.list.each {|v| v.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 at_exit do client.send Jabber::Presence.new.set_type(:unavaliable) end client.send Jabber::Iq.new_rosterget client.send Jabber::Presence.new.set_type(:avaliable) Saber.ui.say ">> Connected to xmpp with #{Rc.server.xmpp.jid}" end def send(files) Saber.ui.debug "SEND #{files.join("\n")}" #client.send Jabber::Presence.new client.send Jabber::Message.new(Rc.client.xmpp.jid, files.join("\n")).set_type(:chat) 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.p.remote_download, :file => true, :include => true) { |p,abs| not Pa.directory?(abs) } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saber-1.0.2 | lib/saber/autofetcher/server.rb |
saber-1.0.1 | lib/saber/autofetcher/server.rb |
saber-1.0.0 | lib/saber/autofetcher/server.rb |