stomp 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/stomp.rb +20 -10
  2. metadata +2 -2
data/lib/stomp.rb CHANGED
@@ -23,14 +23,14 @@ module Stomp
23
23
  # synchronous receives
24
24
  class Connection
25
25
 
26
- def Connection.open(login = "", passcode = "", host='localhost', port=61613, reliable=FALSE)
27
- Connection.new login, passcode, host, port, reliable
26
+ def Connection.open(login = "", passcode = "", host='localhost', port=61613, reliable=FALSE, reconnectDelay=5)
27
+ Connection.new login, passcode, host, port, reliable, reconnectDelay
28
28
  end
29
29
 
30
30
  # Create a connection, requires a login and passcode.
31
31
  # Can accept a host (default is localhost), and port
32
32
  # (default is 61613) to connect to
33
- def initialize(login, passcode, host='localhost', port=61613, reliable=FALSE)
33
+ def initialize(login, passcode, host='localhost', port=61613, reliable=false, reconnectDelay=5)
34
34
  @host = host
35
35
  @port = port
36
36
  @login = login
@@ -39,7 +39,7 @@ module Stomp
39
39
  @read_semaphore = Mutex.new
40
40
  @socket_semaphore = Mutex.new
41
41
  @reliable = reliable
42
- @reconnectDelay = 5
42
+ @reconnectDelay = reconnectDelay
43
43
  @closed = FALSE
44
44
  @subscriptions = {}
45
45
  @failure = NIL
@@ -126,7 +126,7 @@ module Stomp
126
126
  transmit "UNSUBSCRIBE", headers
127
127
  if @reliable
128
128
  subId = name if subId==NIL
129
- @h.delete(subId)
129
+ @subscriptions.delete(subId)
130
130
  end
131
131
  end
132
132
 
@@ -153,7 +153,7 @@ module Stomp
153
153
  end
154
154
 
155
155
  # Receive a frame, block until the frame is received
156
- def receive
156
+ def __old_receive
157
157
  # The recive my fail so we may need to retry.
158
158
  while TRUE
159
159
  begin
@@ -166,12 +166,22 @@ module Stomp
166
166
  end
167
167
  end
168
168
  end
169
-
169
+
170
+ def receive
171
+ super_result = __old_receive()
172
+ if super_result.nil? && @reliable
173
+ $stderr.print "connection.receive returning EOF as nil - resetting connection.\n"
174
+ @socket = nil
175
+ super_result = __old_receive()
176
+ end
177
+ return super_result
178
+ end
179
+
170
180
  private
171
181
  def _receive( s )
172
182
  line = ' '
173
183
  @read_semaphore.synchronize do
174
- line = s.gets
184
+ line = s.gets while line =~ /^\s*$/
175
185
  return NIL if line == NIL
176
186
  Message.new do |m|
177
187
  m.command = line.chomp
@@ -192,8 +202,8 @@ module Stomp
192
202
  m.body << c.chr
193
203
  end
194
204
  end
195
- c = s.getc
196
- raise "Invalid frame termination received" unless c == 10
205
+ #c = s.getc
206
+ #raise "Invalid frame termination received" unless c == 10
197
207
  end
198
208
  end
199
209
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: stomp
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2006-09-22 00:00:00 -07:00
6
+ version: 1.0.3
7
+ date: 2007-01-04 00:00:00 -08:00
8
8
  summary: Ruby client for the Stomp messaging protocol
9
9
  require_paths:
10
10
  - lib