Sha256: 90d33f1b2e72f1ec7a8e1f830867c05ba9ed7bbaf50079f1bd2bcc7089e2f4c2
Contents?: true
Size: 784 Bytes
Versions: 1
Compression:
Stored size: 784 Bytes
Contents
module RubySkynet module Common # Returns a BSON document read from the socket. # Returns nil if the operation times out or if a network # connection failure occurs def self.read_bson_document(socket) bytebuf = BSON::ByteBuffer.new # Read 4 byte size of following BSON document bytes = socket.read(4) # No more data return unless bytes # Read BSON document sz = bytes.unpack("V")[0] raise "Invalid Data received from server:#{bytes.inspect}" unless sz bytebuf.append!(bytes) bytebuf.append!(socket.read(sz - 4)) raise "Celluloid is not returning #{sz} requested bytes. #{bytebuf.length} bytes returned" unless sz == bytebuf.length return BSON.deserialize(bytebuf) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_skynet-0.4.0.pre2 | lib/ruby_skynet/common.rb |