def pack(type, payload=nil)
      size = payload ? payload.to_s.bytes.count : 0
      msg = MAGIC_STRING + [size, type].pack("LL")
      msg << payload.to_s if payload
      msg
    end
def pack(type, payload=nil)
      size = payload ? payload.to_s.bytes.count : 0
      msg = MAGIC_STRING + [size, type].pack("LL")
      msg << payload.to_s if payload
      msg
    end
Packs the message.
 A typical message looks like:
 @example
   <header><payload>
 where a header is:
 @example
   <magic string><message length><message type>

 @param [Integer] type type of the message.
 @param [String] payload payload of the message.