module Moped::Protocol::Message

The base class for building all messages needed to implement the Mongo Wire Protocol. It provides a minimal DSL for defining typed fields for serialization and deserialization over the wire.

@example

class KillCursors < Moped::Protocol::Message
  # header fields
  int32 :length
  int32 :request_id
  int32 :response_to
  int32 :op_code

  # message fields
  int32 :reserved
  int32 :number_of_cursors
  int64 :cursor_ids, type: :array

  # Customize field reader
  def number_of_cursors
    cursor_ids.length
  end
end

Note that all messages must implement the header fields required by the Mongo Wire Protocol, namely:

int32 :length
int32 :request_id
int32 :response_to
int32 :op_code