private byte[] HandlePacket_RemoveElements(byte[] RequestContent)
		{
			var RequestContentStream = new MemoryStream(RequestContent);
			var RequestHeader = RequestContentStream.ReadStruct<RequestHeaderStruct>();

			{
				var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<RequestEntryStruct>();
				var Index = ServerManager.ServerIndices[RequestHeader.RankingIndexId];
				foreach (var RequestEntry in RequestEntries)
				{
					Index.Tree.Remove(Index.GetUserScore(RequestEntry.UserId));
				}
			}

			return new byte[0];
		}
        async private Task<byte[]> HandlePacketAsync_RemoveElements(byte[] RequestContent)
        {
            var RequestContentStream = new MemoryStream(RequestContent);
            var RequestHeader = RequestContentStream.ReadStruct<RequestHeaderStruct>();

            await EnqueueTaskAsync((uint)RequestHeader.RankingIndexId, () =>
            {
                var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<RequestEntryStruct>();
                var Index = ServerManager.ServerIndices[RequestHeader.RankingIndexId];
                foreach (var RequestEntry in RequestEntries)
                {
                    Index.Tree.Remove(Index.GetUserScore(RequestEntry.UserId));
                }
            });
            
            return new byte[0];
        }
        public SoundFXObject(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                Header = s.ReadStruct<SoundFXHeader>();
                if (Header.IsStreamed != 0)
                {
                    WemOffset = s.ReadUInt32();
                    WemLength = s.ReadUInt32();
                }
            }

            UInt32 temp = Header.AudioFileId % 0x32;

            Console.WriteLine("SoundFX ID: {0:X8} AudioFileID: {1:X8} SourceId: {2:X8} temp {3:X8}", Header.ID, Header.AudioFileId, Header.SourceId, temp);
        }
		private byte[] HandlePacket_SetElements(byte[] RequestContent)
		{
			var RequestContentStream = new MemoryStream(RequestContent);

			var RequestHeader = RequestContentStream.ReadStruct<SetElements_RequestHeaderStruct>();
			var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<SetElements_RequestEntryStruct>();

			{
				var Index = ServerManager.ServerIndices[RequestHeader.RankingId];

				foreach (var Request in RequestEntries)
				{
					Index.UpdateUserScore(
						UserId: Request.UserId,
						ScoreTimeStamp: Request.ScoreTimeStamp,
						ScoreValue: Request.ScoreValue
					);
				}
			}

			return new byte[0];
		}
        private static Category UnpackColorCategory(byte[] data)
        {
            var category = new Category();

            using (var ms = new MemoryStream(data))
            using (var reader = new BinaryReader(ms))
            {
                category.Header = ms.ReadStruct<CategoryHeader>();

                for (var i = 0; i < category.Header.ColorCount; i++)
                {
                    var colorRecord = UnpackColorRecord(reader);
                    category.ColorRecords.Add(colorRecord);
                }
                //var alignCheck = reader.ReadInt32();
                //Debug.Assert( alignCheck == category.Header.CategoryDataSize, "The header (and color reads) alignment is not correct." );
            }
            return category;
        }
Ejemplo n.º 6
0
		protected async Task<IEnumerable<BsonDocument>> ReadReplyFromMemory(MemoryStream PacketStream)
		{
			var PacketStreamReader = new BinaryReader(PacketStream);

			var MsgHeader = PacketStream.ReadStruct<MsgHeader>();

			var ResponseFlags = PacketStreamReader.ReadUInt32();
			var CursorID = PacketStreamReader.ReadUInt64();
			var StartingFrom = PacketStreamReader.ReadUInt32();
			var NumberReturned = PacketStreamReader.ReadUInt32();

			var Results = new List<BsonDocument>();

			for (int n = 0; n < NumberReturned; n++)
			{
				Results.Add(BsonSerializer.Deserialize<BsonDocument>(PacketStream));
			}

			return Results;
		}