Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

consistent handling

  • Loading branch information...
commit 73651247675bc8f08c68354dcfa58f6ec4484fc0 1 parent 8bf7720
@joshbuddy joshbuddy authored
View
15 lib/protoplasm/client/blocking_client.rb
@@ -27,28 +27,29 @@ def send_request(field, *args, &blk)
cmd = self.class._types.request_class.new(self.class._types.request_type_field => type.type, type.field => cmd_class.type.new(*args))
cmd.encode(s)
socket = _socket
- socket.write([0, s.size].pack("CQ"))
+ socket.write([Types::Request::NORMAL, s.size].pack("CQ"))
socket.write s
socket.flush
fetch_objects = true
obj = nil
while fetch_objects
- response_code = socket.readpartial(1).unpack("C").first
+ response_byte = socket.read(1)
+ response_code = response_byte.unpack("C").first
case response_code
when Types::Response::NORMAL
fetch_objects = !type.void?
if fetch_objects
- len_buf = ''
- socket.readpartial(8 - len_buf.size, len_buf) while len_buf.size != 8
+ len_buf = socket.read(8)
len = len_buf.unpack("Q").first
- buf = ''
- socket.readpartial(len - buf.size, buf) until buf.size == len
- obj = type.response_class.decode(buf)
+ data = socket.read(len)
+ obj = type.response_class.decode(data)
yield obj if block_given?
end
fetch_objects = false unless type.streaming?
when Types::Response::STOP_STREAMING
fetch_objects = false
+ else
+ raise "Control byte is #{response_byte.inspect}, code is #{response_code.inspect}"
end
end
obj
View
3  lib/protoplasm/server/em_server.rb
@@ -74,7 +74,8 @@ def send_response(*args)
obj = type.response_class.new(*args)
s = ''
obj.encode(s)
- send_data [Types::Response::NORMAL, s.size].pack("CQ")
+ send_data [Types::Response::NORMAL].pack("C")
+ send_data [s.size].pack("Q")
send_data s
end
end
View
2  lib/protoplasm/version.rb
@@ -1,3 +1,3 @@
module Protoplasm
- VERSION = "0.1.1"
+ VERSION = "0.1.2"
end
Please sign in to comment.
Something went wrong with that request. Please try again.