Server.Data.Data C# (CSharp) Méthode

Data() public méthode

public Data ( byte data ) : System
data byte
Résultat System
        public Data(byte[] data)
        {
            //The first four bytes are for the Command
            this.cmdCommand = (Command)BitConverter.ToInt32(data, 0);

            //The next four store the length of the name
            this.playerID = BitConverter.ToInt32(data, 4);

            int nameLen = BitConverter.ToInt32(data, 8);
            //The next four store the length of the message
            int msgLen = BitConverter.ToInt32(data, 12);

            //This check makes sure that strName has been passed in the array of bytes
            if (nameLen > 0)
                this.strName = Encoding.UTF8.GetString(data, 16, nameLen);
            else
                this.strName = null;

            //This checks for a null message field
            if (msgLen > 0)
                this.strMessage = Encoding.UTF8.GetString(data, 16 + nameLen, msgLen);
            else
                this.strMessage = null;
        }

Same methods

Data::Data ( ) : System