Ejemplo n.º 1
0
        public static void DecodePacket(ReadWriteBuffer buffer, int pkgLength, out string targetID, out byte[] rawData)
        {
            int pos = buffer.ReadPos;

            targetID = buffer.PeekStringU8(ref pos);
            rawData  = buffer.PeekArray32(ref pos);
            int encounteredPkgLength = pos - buffer.ReadPos;

            if (encounteredPkgLength > pkgLength)
            {
                throw new Exception("Packet content larger than package itself! pkgLength: "
                                    + pkgLength + ", encounteredPkgLength=" + encounteredPkgLength);
            }
            buffer.ReadPos += pkgLength;
            buffer.DiscardOldData();
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////
        // Constants
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Variables
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Constructors
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Properties
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Methods
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Static Methods
        ////////////////////////////////////////////////////////////////

        public static void WritePacket(byte[] rawData, ReadWriteBuffer buffer)
        {
            buffer.WriteArray32(rawData);
        }