lib/stomp.rb in stomp-1.0.3 vs lib/stomp.rb in stomp-1.0.4
- old
+ new
@@ -22,11 +22,11 @@
# Low level connection which maps commands and supports
# synchronous receives
class Connection
def Connection.open(login = "", passcode = "", host='localhost', port=61613, reliable=FALSE, reconnectDelay=5)
- Connection.new login, passcode, host, port, reliable, reconnectDelay
+ Connection.new login, passcode, host, port, reliable, reconnectDelay
end
# Create a connection, requires a login and passcode.
# Can accept a host (default is localhost), and port
# (default is 61613) to connect to
@@ -258,11 +258,25 @@
# in that thread if you have much message volume.
class Client
# Accepts a username (default ""), password (default ""),
# host (default localhost), and port (default 61613)
- def initialize user="", pass="", host="localhost", port=61613, reliable=FALSE
+ def initialize user="", pass="", host="localhost", port=61613, reliable=false
+ if user =~ /stomp:\/\/(\w+):(\d+)/
+ user = ""
+ pass = ""
+ host = $1
+ port = $2
+ reliable = false
+ elsif user =~ /stomp:\/\/(\w+):(\w+)@(\w+):(\d+)/
+ user = $1
+ pass = $2
+ host = $3
+ port = $4
+ reliable = false
+ end
+
@id_mutex = Mutex.new
@ids = 1
@connection = Connection.open user, pass, host, port, reliable
@listeners = {}
@receipt_listeners = {}
@@ -293,11 +307,11 @@
@listener_thread.join
end
# Accepts a username (default ""), password (default ""),
# host (default localhost), and port (default 61613)
- def self.open user="", pass="", host="localhost", port=61613
- Client.new user, pass, host, port
+ def self.open user="", pass="", host="localhost", port=61613, reliable=false
+ Client.new user, pass, host, port, reliable
end
# Begin a transaction by name
def begin name, headers={}
@connection.begin name, headers