public void Send <TClass>(BaseContainer <TClass> message, BaseAgenda agenda) { Container messageRequest = message.GetContainer(); switch (agenda.Type) { case ChannelType.General: { foreach (KeyValuePair <Guid, WsConnection> connection in _connections.Where(author => author.Value.Login != message.Author)) { connection.Value.Send(messageRequest); } break; } case ChannelType.Private: { if (_connections.Values.Count == 0) { return; } _connections.Values.FirstOrDefault(item => item.Login == ((PrivateAgenda)agenda).Target)?.Send(messageRequest); break; } } }
public void Send <TClass>(BaseContainer <TClass> message, BaseAgenda agenda) { byte[] messageBroadcast = ConvertToBytes(message.GetContainer()); switch (agenda.Type) { case ChannelType.General: { foreach (KeyValuePair <IPEndPoint, TcpConnection> connection in _connections.Where(author => author.Value.Login != message.Author)) { connection.Value.Send(messageBroadcast); } break; } case ChannelType.Private: { if (_connections.Values.Count == 0) { return; } _connections.Values.FirstOrDefault(item => item.Login == ((PrivateAgenda)agenda).Target)?.Send(messageBroadcast); break; } case ChannelType.Group: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } }
public void Send <TClass>(BaseContainer <TClass> message) { _sendQueue.Enqueue(message.GetContainer()); if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0) { SendImpl(); } }
public void Send(BaseContainer request) { _sendQueue.Enqueue(request.GetContainer()); if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0) { SendImpl(); } }
public void Send <TClass>(BaseContainer <TClass> message) { byte[] messageBroadcast = ConvertToBytes(message.GetContainer()); _sendQueue.Enqueue(messageBroadcast); if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0) { SendImpl(); } }