Sha256: ec48d7011752e64f76b37ff954db969ba2f59e6f2d4b028ff0ef8239e7830be5

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

# --
# Copyright (C) 2008-2009 10gen Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ++

require 'mongo/util/byte_buffer'

module Mongo

  class MessageHeader

    HEADER_SIZE = 16

    def initialize()
      @buf = ByteBuffer.new
    end

    def read_header(db)
      @buf.rewind
      @buf.put_array(db.receive_full(HEADER_SIZE).unpack("C*"))
      raise "Short read for DB response header: expected #{HEADER_SIZE} bytes, saw #{@buf.size}" unless @buf.size == HEADER_SIZE
      @buf.rewind
      @size = @buf.get_int
      @request_id = @buf.get_int
      @response_to = @buf.get_int
      @op = @buf.get_int
      self
    end

    def dump
      @buf.dump
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
mongodb-mongo-0.13 lib/mongo/message/message_header.rb
mongodb-mongo-0.14.1 lib/mongo/message/message_header.rb
mongodb-mongo-0.14 lib/mongo/message/message_header.rb
pahagon-mongo-abd-0.14.1 lib/mongo/message/message_header.rb
mongo-0.15.1 lib/mongo/message/message_header.rb
mongo-0.15 lib/mongo/message/message_header.rb