Exemplo n.º 1
0
 void InvokeTags(ulong user, ServiceData data)
 {
     foreach (PatchTag tag in data.Tags)
         if (TagReceived.Contains(tag.Service, tag.DataType))
             TagReceived[tag.Service, tag.DataType].Invoke(user, tag.Tag);
 }
Exemplo n.º 2
0
        public static ServiceData Decode(byte[] data)
        {
            G2Header root = new G2Header(data);

            G2Protocol.ReadPacket(root);

            if (root.Name != LocationPacket.Data)
                return null;

            ServiceData packet = new ServiceData();
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                    continue;

                switch (child.Name)
                {
                    case Packet_Date:
                        packet.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                        break;

                    case Packet_Tag:
                        packet.Tags.Add(PatchTag.FromBytes(child.Data, child.PayloadPos, child.PayloadSize));
                        break;
                }
            }

            return packet;
        }
Exemplo n.º 3
0
        public void UpdateLocal()
        {
            ServiceData data = new ServiceData();
            data.Date = Core.TimeNow.ToUniversalTime();

            foreach (uint service in GetTag.HandlerMap.Keys)
                foreach (uint datatype in GetTag.HandlerMap[service].Keys)
                {
                    PatchTag tag = new PatchTag();

                    tag.Service = service;
                    tag.DataType = datatype;
                    tag.Tag = GetTag[service, datatype].Invoke();

                    if (tag.Tag != null)
                    {
                        Debug.Assert(tag.Tag.Length < 8);

                        if (tag.Tag.Length < 8)
                            data.Tags.Add(tag);
                    }
                }

            Cache.UpdateLocal("", null, data.Encode(Network.Protocol));
        }