/// <summary>
        /// Factor method to create a message from a byte list
        /// </summary>
        /// <param name="messageBytes">A byte list from which the message will be decoded</param>
        /// <returns>A new message of the right specialization</returns>
        public static new GetStatus Create(ByteList messageBytes)
        {
            GetStatus result = null;

            if (messageBytes == null || messageBytes.RemainingToRead < MinimumEncodingLength)
                throw new ApplicationException("Invalid message byte array");
            else if (messageBytes.PeekInt16() != ClassId)
                throw new ApplicationException("Invalid message class id");
            else
            {
                result = new GetStatus();
                result.Decode(messageBytes);
            }

            return result;
        }
示例#2
0
        /// <summary>
        /// Factor method to create a message from a byte list
        /// </summary>
        /// <param name="messageBytes">A byte list from which the message will be decoded</param>
        /// <returns>A new message of the right specialization</returns>
        new public static GetStatus Create(ByteList messageBytes)
        {
            GetStatus result = null;

            if (messageBytes == null || messageBytes.RemainingToRead < MinimumEncodingLength)
            {
                throw new ApplicationException("Invalid message byte array");
            }
            else if (messageBytes.PeekInt16() != ClassId)
            {
                throw new ApplicationException("Invalid message class id");
            }
            else
            {
                result = new GetStatus();
                result.Decode(messageBytes);
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// Factor method to create a message from a byte list
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns>A new message of the right specialization</returns>
        new public static Request Create(ByteList bytes)
        {
            Request result = null;

            if (bytes == null || bytes.RemainingToRead < MinimumEncodingLength)
            {
                throw new ApplicationException("Invalid message byte array");
            }

            Int16 msgType = bytes.PeekInt16();

            switch (msgType)
            {
            case (Int16)MESSAGE_CLASS_IDS.JoinGame:
                result = JoinGame.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.AddComponent:
                result = AddComponent.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.RemoveComponent:
                result = RemoveComponent.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.StartGame:
                result = StartGame.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.EndGame:
                result = EndGame.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.GetResource:
                result = GetResource.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.TickDelivery:
                result = TickDelivery.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.ValidateTick:
                result = ValidateTick.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.Move:
                result = Move.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.ThrowBomb:
                result = ThrowBomb.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.Eat:
                result = Eat.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.ChangeStrength:
                result = ChangeStrength.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.Collaborate:
                result = Collaborate.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.GetStatus:
                result = GetStatus.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.ExitGame:
                result = ExitGame.Create(bytes);
                break;

            case (Int16)MESSAGE_CLASS_IDS.StartUpdateStream:
                result = StartUpdateStream.Create(bytes);
                break;

            default:
                throw new ApplicationException("Invalid Message Class Id");
            }

            return(result);
        }