require "xmpp4r/client" require "drb" module Saber class Client class << self def start client = Client.new client.start Thread.list.each {|v| v.join} end end attr_reader :client, :downloader def initialize @client = Jabber::Client.new(Jabber::JID.new(Rc.client.xmpp.jid)) @downloader = Downloader.new end def start client.connect Rc.client.xmpp.host, Rc.client.xmpp.port client.auth Rc.client.xmpp.password client.add_message_callback { |msg| pd msg.from.bare if msg.from.bare == Rc.server.xmpp.jid files = msg.body.split("\n") $log.debug "RECV #{files}" downloader.add *files end } client.send Jabber::Presence.new Saber.ui.say ">> Connected to xmpp with #{Rc.client.xmpp.jid}" end def stop @client.close! end end class DRbClient attr_reader :server def initialize DRb.start_service @server = DRbObject.new_with_uri(Rc.drb_uri) Saber.ui.say ">> DRbClient connected to #{Rc.drb_uri}" end def add(*names) Saber.ui.say "ADD #{names}" server.add(*names) end end end