public void Publish(ulong target, byte[] data) { TempData temp = new TempData(target) { TTL = 60, Data = data }; byte[] encoded = temp.Encode(Network.Protocol); Store_Local(new DataReq(null, target, ServiceID, DataType, encoded)); Network.Store.PublishNetwork(target, ServiceID, DataType, encoded); }
public static TempData Decode(ulong target, byte[] data) { G2Header root = new G2Header(data); G2Protocol.ReadPacket(root); if (root.Name != TempPacket.Data) return null; TempData temp = new TempData(target); G2Header child = new G2Header(root.Data); while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD) { if (!G2Protocol.ReadPayload(child)) continue; switch (child.Name) { case Packet_TTL: temp.TTL = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Data: temp.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); break; } } return temp; }