public Task <MessageResult> AcceptAsync(Client client) { clients.Add(client.Id, client); var result = new SuccessMessageResult(); return(Task.FromResult <MessageResult>(result)); }
public async Task <MessageResult> ReceiveAsync(string message) { await Task.Delay(3); messages.Add($"Server: {message}"); var result = new SuccessMessageResult(); return(result); }
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); }