Example #1
0
 /// <summary>
 /// Constructor used by all specializations, which in turn are used by
 /// senders of a message 
 /// </summary>
 /// <param name="conversationId">conversation id</param>
 /// <param name="status">Status of the ack/nak</status>
 /// <param name="note">error message or note</note>
 public AckNak(PossibleStatus status, int intResult, DistributableObject objResult, string message, string note)
     : base(Reply.PossibleTypes.AckNak, status, note)
 {
     IntResult = intResult;
     ObjResult = objResult;
     Message = message;
 }
        public DistributableObject GetDistributableObject()
        {
            DistributableObject obj = null;
            bool isPresent          = GetBool();

            if (isPresent)
            {
                obj = DistributableObject.Create(this);
            }

            return(obj);
        }
 public void Add(DistributableObject obj)
 {
     if (obj == null)
     {
         Add(false);
     }
     else
     {
         Add(true);
         obj.Encode(this);
     }
 }
Example #4
0
        public static DistributableObject Create(ByteList bytes)
        {
            DistributableObject result = null;

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

            DISTRIBUTABLE_CLASS_IDS objType = (DISTRIBUTABLE_CLASS_IDS)bytes.PeekInt16();

            switch (objType)
            {
            case DISTRIBUTABLE_CLASS_IDS.MessageNumber:
                result = MessageNumber.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.Bomb:
                result = Bomb.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.AgentInfo:
                result = AgentInfo.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.AgentList:
                result = AgentList.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.EndPoint:
                result = EndPoint.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.Excuse:
                result = Excuse.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.FieldLocation:
                result = FieldLocation.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.GameConfiguration:
                result = GameConfiguration.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.PlayingFieldLayout:
                result = PlayingFieldLayout.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.Tick:
                result = Tick.Create(bytes);
                break;

            case DISTRIBUTABLE_CLASS_IDS.WhiningTwine:
                result = WhiningTwine.Create(bytes);
                break;

            default:
                throw new ApplicationException(string.Format("Invalid Class Id={0}", objType));
            }
            return(result);
        }
Example #5
0
 public AckNak(PossibleStatus status, DistributableObject objResult, string message)
     : this(status, 0, objResult, message, string.Empty)
 {
 }
 /// <summary>
 /// Constructor used by all specializations, which in turn are used by
 /// senders of a message 
 /// </summary>
 /// <param name="conversationId">conversation id</param>
 /// <param name="status">Status of the ack/nak</status>
 /// <param name="note">error message or note</note>
 public ResourceReply(PossibleStatus status, DistributableObject resource, string note = null)
     : base(Reply.PossibleTypes.ResourceReply, status, note)
 {
     Resource = resource;
 }
 public void Add(DistributableObject obj)
 {
     if (obj == null)
         Add(false);
     else
     {
         Add(true);
         obj.Encode(this);
     }
 }