lib/xmpp4r-simple.rb in xmpp4r-simple-0.8.6 vs lib/xmpp4r-simple.rb in xmpp4r-simple-0.8.7
- old
+ new
@@ -16,18 +16,21 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/roster'
+require 'xmpp4r/vcard'
module Jabber
class ConnectionError < StandardError #:nodoc:
end
class Contact #:nodoc:
+ include DRb::DRbUndumped if defined?(DRb::DRbUndumped)
+
def initialize(client, jid)
@jid = jid.respond_to?(:resource) ? jid : JID.new(jid)
@client = client
end
@@ -71,10 +74,12 @@
end
end
class Simple
+ include DRb::DRbUndumped if defined?(DRb::DRbUndumped)
+
# Create a new Jabber::Simple client. You will be automatically connected
# to the Jabber server and your status message will be set to the string
# passed in as the status_message argument.
#
# jabber = Jabber::Simple.new("me@example.com", "password", "Chat with me - Please!")
@@ -139,11 +144,11 @@
@presence = presence
@status_message = message
stat_msg = Presence.new(@presence, @status_message)
send!(stat_msg)
end
-
+
# Ask the users specified by jids for authorization (i.e., ask them to add
# you to their contact list). If you are already in the user's contact list,
# add() will not attempt to re-request authorization. In order to force
# re-authorization, first remove() the user, then re-add them.
#
@@ -323,10 +328,16 @@
attempts = 0
begin
attempts += 1
client.send(msg)
rescue Errno::EPIPE, IOError => e
- sleep 0.33
+ sleep 1
+ disconnect
+ reconnect
+ retry unless attempts > 3
+ raise e
+ rescue Errno::ECONNRESET => e
+ sleep (attempts^2) * 60 + 60
disconnect
reconnect
retry unless attempts > 3
raise e
end