private bool UserJoinGroupMessagesEqual(UserJoinGroupMessage x, UserJoinGroupMessage y)
 {
     return(StringEqual(x.UserId, y.UserId) &&
            StringEqual(x.GroupName, y.GroupName) &&
            x.TracingId == y.TracingId &&
            x.Ttl == y.Ttl);
 }
Example #2
0
        public Task UserAddToGroupAsync(string userId, string groupName, TimeSpan ttl, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(userId));
            }

            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(groupName));
            }

            if (ttl < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(ttl), TtlOutOfRangeErrorMessage);
            }
            var message = new UserJoinGroupMessage(userId, groupName)
            {
                Ttl = (int)ttl.TotalSeconds
            }.WithTracingId();

            if (message.TracingId != null)
            {
                MessageLog.StartToAddUserToGroup(Logger, message);
            }
            return(WriteAsync(message));
        }
Example #3
0
 public static void StartToAddUserToGroup(ILogger logger, UserJoinGroupMessage message)
 {
     if (message.Ttl == null)
     {
         _startToAddUserToGroup(logger, message.TracingId, message.UserId, message.GroupName, null);
     }
     else
     {
         _startToAddUserToGroupWithTtl(logger, message.TracingId, message.UserId, message.GroupName, message.Ttl, null);
     }
 }
Example #4
0
        public Task UserAddToGroupAsync(string userId, string groupName, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(userId));
            }

            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(groupName));
            }

            var message = new UserJoinGroupMessage(userId, groupName);

            return(ServiceConnectionContainer.WriteAsync(message));
        }
Example #5
0
        public Task UserAddToGroupAsync(string userId, string groupName, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(userId));
            }

            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(groupName));
            }

            var message = new UserJoinGroupMessage(userId, groupName).WithTracingId();

            Log.StartToAddUserToGroup(Logger, message);
            return(WriteAsync(message));
        }
        public Task UserAddToGroupAsync(string userId, string groupName, TimeSpan ttl, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(userId));
            }

            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException(NullOrEmptyStringErrorMessage, nameof(groupName));
            }

            if (ttl < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(ttl), TtlOutOfRangeErrorMessage);
            }
            var message = new UserJoinGroupMessage(userId, groupName)
            {
                Ttl = (int)ttl.TotalSeconds
            };

            return(ServiceConnectionContainer.WriteAsync(message));
        }
Example #7
0
 private bool UserJoinGroupMessagesEqual(UserJoinGroupMessage x, UserJoinGroupMessage y)
 {
     return(StringEqual(x.UserId, y.UserId) && StringEqual(x.GroupName, y.GroupName));
 }