Module: Riakpb::Util::Decode
- Included in:
- Client::Rpc
- Defined in:
- lib/riakpb/util/decode.rb
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#decode_message(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/riakpb/util/decode.rb', line 11 def () pb_len = 0 pb_mc = '' pb_msg = '' remain = '' until .empty? pb_len = [PLEN].unpack('N')[0] # message[0..3]unpack('N')[0] pb_mc = pb_mc + [PBMC] # prior message codes + message[4] prange = POFF..(pb_len+3) # range for the start->finish of the pb message mrange = (pb_len+4)..(.size-1) # range for any remaining portions of message break if(prange.count > [prange].size) pb_msg = pb_msg + [prange] = [mrange] # message[(5+pb_len)..(message.size)] end [pb_msg, pb_mc.unpack("c" * pb_mc.size), ] end |
#message_remaining?(message) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/riakpb/util/decode.rb', line 34 def () pb_len = [PLEN].unpack('N')[0] msg_len = .size - PBMC puts "pb_len:#{pb_len}" puts "msg_len:#{msg_len}" puts "message:#{.inspect}" return false if pb_len == msg_len return true if pb_len > msg_len return ([(pb_len+4)..(msg_len-1)]) end |