/// <summary>
        /// Encodes one message.
        /// </summary>
        /// <param name="output"> The output stream to encode to </param>
        /// <param name="message"> The message to encode </param>
        /// <exception cref="IOException"> When an IO error occurs </exception>
        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @SuppressWarnings("unchecked") public void encode(java.io.DataOutputStream output, RemoteMessage message) throws java.io.IOException
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void encode(DataOutputStream output, RemoteMessage message)
        {
            RemoteMessageType type = encodingMap[message.GetType()];

            System.IO.MemoryStream messageOutputBytes = new System.IO.MemoryStream();
            DataOutput             messageOutput      = new DataOutputStream(messageOutputBytes);

            RemoteMessageCodec <RemoteMessage> codec = type.codec;

            codec.encode(messageOutput, message);

            output.writeInt(messageOutputBytes.Capacity + 2);
            output.writeByte((sbyte)type.ordinal());
            output.writeByte((sbyte)type.codec.version(message));
            messageOutputBytes.WriteTo(output);
        }