Exemple #1
0
        public static async Task <bool> BroadcastWithAckWithTrackAsync(this DataLinkCollection dlc, string group, string content)
        {
            var length = Encoding.UTF8.GetByteCount(content);

            using (var owner = ExactSizeMemoryPool.Shared.Rent(length))
            {
                Encoding.UTF8.GetBytes(content, owner.Memory.Span);
                return(await dlc.BroadcastWithAckWithTrackAsync(group, owner.Memory));
            }
        }
Exemple #2
0
        private async Task GroupBroadcastAsync(string line)
        {
            var parts = line.Substring(2).Trim().Split(" ", 2);

            if (parts.Length < 2)
            {
                Console.WriteLine("Bad command.");
                return;
            }
            var groupName = parts[0];

            if (groupName.Length == 0 || groupName.Length > 1024 || !NameRegex.IsMatch(groupName))
            {
                Console.WriteLine("Bad command.");
                return;
            }
            if (!await _dlc.BroadcastWithAckWithTrackAsync(groupName, parts[1]))
            {
                Console.WriteLine($"No member in group {groupName}.");
            }
        }