code: public void encode(final BsonOutput bsonOutput, final SessionContext sessionContext) {
          notNull("sessionContext", sessionContext);
          int messageStartPosition = bsonOutput.getPosition();
          writeMessagePrologue(bsonOutput);
          EncodingMetadata encodingMetadata = encodeMessageBodyWithMetadata(bsonOutput, sessionContext);
          backpatchMessageLength(messageStartPosition, bsonOutput);
          this.encodingMetadata = encodingMetadata;
      }
docs: Encoded the message to the given output.
  
  @param bsonOutput the output
  @param sessionContext the session context