Ejemplo n.º 1
0
        public Task <MessageResult> AcceptAsync(Client client)
        {
            clients.Add(client.Id, client);

            var result = new SuccessMessageResult();

            return(Task.FromResult <MessageResult>(result));
        }
Ejemplo n.º 2
0
        public async Task <MessageResult> ReceiveAsync(string message)
        {
            await Task.Delay(3);

            messages.Add($"Server: {message}");

            var result = new SuccessMessageResult();

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <MessageResult> SendAsync(string message)
        {
            MessageResult result = new ErrorMessageResult();

            if (clients.Count > 0)
            {
                var tasks = new List <Task>();

                foreach (var client in clients.Values)
                {
                    var task = client.ReceiveAsync(message);
                    tasks.Add(task);
                }

                await Task.WhenAll(tasks);

                result = new SuccessMessageResult();
            }

            return(result);
        }