Example #1
0
 public EnhancedNotification(DeviceToken deviceToken, IPayload payload, uint identifier, TimeSpan? expiry)
 {
     this.deviceToken = deviceToken;
     this.payload = payload;
     this.identifier = identifier;
     this.expiry = expiry;
 }
Example #2
0
        public void Read(Stream s)
        {
            BinaryReader br = new BinaryReader(s);
            magic = br.ReadUInt32();
            command = br.ReadBytes(12);
            length = br.ReadUInt32();
            checksum = br.ReadBytes(4);

            switch (strcmd)
            {
                case "addr":
                    payload = Addr.FromStream(s);
                    break;
                case "alert":
                    payload = Alert.FromStream(s);
                    break;
                case "block":
                    payload = Block.FromStream(s);
                    break;
                case "getaddr":
                    payload = GetAddr.FromStream(s);
                    break;
                case "getblocks":
                    payload = GetBlocks.FromStream(s);
                    break;
                case "getdata":
                    payload = GetData.FromStream(s);
                    break;
                case "getheaders":
                    payload = GetHeaders.FromStream(s);
                    break;
                case "headers":
                    payload = Headers.FromStream(s);
                    break;
                case "inv":
                    payload = Inv.FromStream(s);
                    break;
                case "ping":
                    payload = Ping.FromStream(s);
                    break;
                case "tx":
                    payload = Tx.FromStream(s);
                    break;
                case "verack":
                    payload = VerAck.FromStream(s);
                    break;
                case "version":
                    payload = Version.FromStream(s);
                    break;
                default:
                    payload = UnknownPayload.FromStream(s, length, command);
                    break;
            }
        }
Example #3
0
 public Message(String command, IPayload payload, bool TestNet = false)
 {
     SHA256 sha256 = new SHA256Managed();
     Byte[] payloadBytes = payload.ToBytes();
     if (!TestNet)
         this.magic = 0xD9B4BEF9;
     else
         this.magic = 0x0709110B;
     this.command = Encoding.ASCII.GetBytes(command).Concat(new Byte[12 - command.Length]).ToArray();
     this.length = (UInt32)payloadBytes.Length;
     this.checksum = sha256.ComputeHash(sha256.ComputeHash(payloadBytes)).Take(4).ToArray();
     this.payload = payload;
 }
		public void Evaluate(int SpreadMax)
		{
			if (FWidth.IsChanged || FHeight.IsChanged || FMode.IsChanged || FBalanced.IsChanged)
			{
				switch (FMode[0])
				{
					case PayloadMode.Graycode:
						{
							FPayload = new PayloadGraycode(FWidth[0], FHeight[0], FBalanced[0]);
						}
						break;
				}

				FOutput[0] = FPayload;
				FCount[0] = (int)FPayload.FrameCount;
			}
		}
Example #5
0
 /// <summary>
 ///     Construct DTO model without payload object using WebApiServiceException.
 /// </summary>
 /// <param name="exception">the exception</param>
 public DtoModelOutgoing(ManagedException exception, IPayload errorDetails = null)
 {
     Payload = errorDetails;
     Service = new ServiceObject(exception.ErrorCode, exception.ErrorMessage);
 }
Example #6
0
 /// <summary>
 ///     Construct DTO model using payload object.
 ///     The error code is ZERO and error message is NULL.
 /// </summary>
 /// <param name="payload">the DTO payload object</param>
 public DtoModelOutgoing(IPayload payload)
 {
     Payload = payload;
     Service = new ServiceObject();
 }
Example #7
0
 public void DecodePayload()
 {
     if (PayloadMapping.ContainsKey(Type))
     {
         Payload = (IPayload) Activator.CreateInstance(PayloadMapping[Type]);
         Payload.Decode(BytePayload);
     }
     else
     {
         throw new ArgumentException("Type not found in map");
     }
 }
Example #8
0
 public void Reset()
 {
     ChunkType = 0;
     ChunkStreamId = 0;
     TimeStamp = 0;
     Length = 0;
     Type = default(PayloadType);
     MessageStreamId = 0;
     HasAbsTimestamp = false;
     BytesRead = 0;
     BytePayload = new byte[0];
     Payload = default(IPayload);
 }
Example #9
0
        IFluentLogObject IFluentLogObject.WithExtraPayload(IPayload payload)
        {
            if (payload == null)
                throw new ArgumentNullException("payload");

            PayloadTypes pldt;

            try
            {
                pldt = payload.GetType().GetPayloadType();
            }
            catch (ArgumentException x)
            {
                throw new ArgumentException("Given payload is of unkown type.", x);
            }

            if ((this.PayloadTypes & pldt) == 0)
                this.PayloadTypes |= pldt;
            else
                throw new InvalidOperationException("The object already contains a payload of the same type." + Environment.NewLine + "Duplicated type: " + pldt);

            this.payloads.Add(payload);

            return this;
        }
Example #10
0
 public SimpleNotification(DeviceToken token, IPayload payload)
 {
     this.deviceToken = token;
     this.payload = payload;
 }