StompMq 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stompmq/connection.rb +13 -8
- metadata +2 -2
data/lib/stompmq/connection.rb
CHANGED
@@ -33,16 +33,16 @@ module StompMq
|
|
33
33
|
|
34
34
|
# Send a STOMP message to a queue.
|
35
35
|
def send_message(opts = { :queue => nil, :header => {}, :content => {} })
|
36
|
-
queue =
|
37
|
-
content =
|
38
|
-
header =
|
36
|
+
queue = opts[:queue]
|
37
|
+
content = opts[:content]
|
38
|
+
header = opts[:header]
|
39
39
|
|
40
40
|
header = {:destination => queue}.merge(header)
|
41
41
|
send_frame :send, header, content
|
42
42
|
end
|
43
43
|
|
44
44
|
# Receive a STOMP message.
|
45
|
-
def receive_message(timeout =
|
45
|
+
def receive_message(timeout = nil)
|
46
46
|
frame = receive_frame(timeout)
|
47
47
|
return nil if !frame
|
48
48
|
raise StompErrorReceived.new(frame.content) if frame.cmd == 'ERROR'
|
@@ -65,14 +65,19 @@ module StompMq
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Receive a standard STOMP frame.
|
68
|
-
def receive_frame(timeout =
|
69
|
-
|
70
|
-
|
68
|
+
def receive_frame(timeout = nil)
|
69
|
+
frame = nil
|
70
|
+
# FIXME: we'll violate the timeout given if half a packet comes in at first, then more later.
|
71
|
+
until frame do
|
72
|
+
return nil if receive_data(timeout) == nil
|
73
|
+
frame = parse_frame
|
74
|
+
end
|
75
|
+
frame
|
71
76
|
end
|
72
77
|
|
73
78
|
# Receive data waiting on a socket. If timeout is passed, block for this many seconds,
|
74
79
|
# otherwise don't block, return nil if no frame is waiting.
|
75
|
-
def receive_data(timeout =
|
80
|
+
def receive_data(timeout = nil)
|
76
81
|
sock_ready = select([@sock], nil, nil, timeout)
|
77
82
|
return nil if !sock_ready
|
78
83
|
@buffer += @sock.recv(1024)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: StompMq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sarah Nordstrom
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-06 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|