示例#1
0
        private static async ValueTask <RedisResult> JoinedParticipantsRepository_RemoveParticipantSafe(
            IKeyValueDatabaseActions actions, string participantId, string participantKey, string conferenceKeyTemplate,
            string connectionId)
        {
            var conferenceId = await actions.GetAsync(participantKey);

            if (conferenceId == null)
            {
                return(RedisResult.Create(RedisValue.Null));
            }

            var conferenceKey      = conferenceKeyTemplate.Replace("*", conferenceId);
            var actualConnectionId = await actions.HashGetAsync(conferenceKey, participantId);

            if (actualConnectionId == connectionId)
            {
                await actions.KeyDeleteAsync(participantKey);

                await actions.HashDeleteAsync(conferenceKey, participantId);

                return(RedisResult.Create(true));
            }

            return(RedisResult.Create(false));
        }
示例#2
0
        private static async ValueTask <RedisResult> JoinedParticipantsRepository_RemoveParticipant(
            IKeyValueDatabaseActions actions, string participantId, string participantKey, string conferenceKeyTemplate)
        {
            var conferenceId = await actions.GetAsync(participantKey);

            if (conferenceId == null)
            {
                return(RedisResult.Create(RedisValue.Null));
            }

            await actions.KeyDeleteAsync(participantKey);

            var conferenceKey        = conferenceKeyTemplate.Replace("*", conferenceId);
            var previousConnectionId = await actions.HashGetAsync(conferenceKey, participantId);

            await actions.HashDeleteAsync(conferenceKey, participantId);

            return(RedisResult.Create(new RedisValue[] { conferenceId, previousConnectionId }));
        }