Пример #1
0
 /// <summary>
 /// Initialize a PacketWriter to read the specified stream using
 /// the provided encoding for strings.
 /// </summary>
 /// <param name="stream">Destination for data written</param>
 /// <param name="majorVersion">Major version of the serialization protocol</param>
 /// <param name="minorVersion">Minor version of the serialization protocol</param>
 public PacketWriter(Stream stream, int majorVersion, int minorVersion)
 {
     m_Stream       = stream;
     m_Writer       = new FieldWriter(stream, new UniqueStringList(), majorVersion, minorVersion);
     m_Buffer       = new MemoryStream();
     m_BufferWriter = new FieldWriter(m_Buffer, m_Writer.Strings, majorVersion, minorVersion);
     m_CachedTypes  = new PacketDefinitionList();
     m_PacketCache  = new PacketCache();
 }
Пример #2
0
        /// <summary>
        /// Initialize a PacketReader to read the specified stream using
        /// the provided encoding for strings.
        /// </summary>
        /// <param name="stream">Data to be read</param>
        /// <param name="inputIsReadOnly">Indicates if the input can be assumed fixed in length</param>
        /// <param name="majorVersion">Major version of the serialization protocol</param>
        /// <param name="minorVersion">Minor version of the serialization protocol</param>
        public PacketReader(Stream stream, bool inputIsReadOnly, int majorVersion, int minorVersion)
        {
            m_Stream          = stream;
            m_InputIsReadOnly = inputIsReadOnly;
            m_MajorVersion    = majorVersion;
            m_MinorVersion    = minorVersion;

            // m_ReleaseStream = false; // m_Stream was passed in to us, don't release it upon Dispose()!
            // (false by default) If we were invoked from another constructor, they will overwrite m_ReleaseStream correctly
            m_Reader        = new FieldReader(stream, new UniqueStringList(), majorVersion, minorVersion);
            m_cachedTypes   = new PacketDefinitionList();
            m_PacketFactory = new PacketFactory();

            if ((inputIsReadOnly) && (m_Stream != null))
            {
                m_StreamLength = m_Stream.Length;
            }
        }