Beispiel #1
0
        public static async Task <ReviveEventRecord> Parse(JsonObject json, bool squad)
        {
            ReviveEventRecord record = new ReviveEventRecord();

            record.squad = squad;
            JsonString characterId   = json["character_id"] as JsonString;
            JsonString otherId       = json["other_id"] as JsonString;
            JsonString timestamp     = json["timestamp"] as JsonString;
            var        characterTask = PS2APIUtils.GetCharacterName(characterId);
            var        otherTask     = PS2APIUtils.GetCharacterName(otherId);

            long ts;

            if (timestamp == null || !long.TryParse(timestamp.InnerString, out ts))
            {
                ts = 0;
            }
            record.timestamp = ts;

            await Task.WhenAll(characterTask, otherTask);

            record.reviver = await characterTask;
            record.revived = await otherTask;
            return(record);
        }
Beispiel #2
0
        async Task <ReviveEventRecord> ProcessReviveRecord(JsonObject payload, string xpId)
        {
            ReviveEventRecord expRecord = await ReviveEventRecord.Parse(payload, xpId == PS2APIConstants.ExperienceIdSquadRevive);

            foreach (var handler in handlers)
            {
                handlersLock.EnterReadLock();
                try
                {
                    handler.Handle(expRecord);
                }
                finally
                {
                    handlersLock.ExitReadLock();
                }
            }
            return(expRecord);
        }