示例#1
0
        public void UploadMetadata(BroadcastMetadata metadata)
        {
            this.Check();

            lock (_lockObject)
            {
                _networkManager.Upload(metadata);
            }
        }
示例#2
0
        protected override void ProtectedImport(Stream stream, BufferManager bufferManager, int depth)
        {
            using (var reader = new ItemStreamReader(stream, bufferManager))
            {
                while (reader.Available > 0)
                {
                    int id = (int)reader.GetUInt32();

                    if (id == (int)SerializeId.BroadcastMetadatas)
                    {
                        for (int i = (int)reader.GetUInt32() - 1; i >= 0; i--)
                        {
                            this.ProtectedBroadcastMetadatas.Add(BroadcastMetadata.Import(reader.GetStream(), bufferManager));
                        }
                    }
                }
            }
        }
示例#3
0
            public bool SetMetadata(BroadcastMetadata broadcastMetadata)
            {
                using (_lockManager.WriteLock())
                {
                    var now = DateTime.UtcNow;

                    if (broadcastMetadata == null ||
                        broadcastMetadata.Type == null ||
                        (broadcastMetadata.CreationTime - now).TotalMinutes > 30 ||
                        broadcastMetadata.Certificate == null)
                    {
                        return(false);
                    }

                    if (!_broadcastMetadatas.TryGetValue(broadcastMetadata.Type, out var dic))
                    {
                        dic = new Dictionary <Signature, BroadcastMetadata>();
                        _broadcastMetadatas[broadcastMetadata.Type] = dic;
                    }

                    var signature = broadcastMetadata.Certificate.GetSignature();

                    if (!dic.TryGetValue(signature, out var tempMetadata) ||
                        broadcastMetadata.CreationTime > tempMetadata.CreationTime)
                    {
                        if (!broadcastMetadata.VerifyCertificate())
                        {
                            return(false);
                        }

                        dic[signature] = broadcastMetadata;
                    }

                    return(true);
                }
            }