Ejemplo n.º 1
0
        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;
            }
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        public void Send <TClass>(BaseContainer <TClass> message)
        {
            _sendQueue.Enqueue(message.GetContainer());

            if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0)
            {
                SendImpl();
            }
        }
Ejemplo n.º 4
0
        public void Send(BaseContainer request)
        {
            _sendQueue.Enqueue(request.GetContainer());

            if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0)
            {
                SendImpl();
            }
        }
Ejemplo n.º 5
0
        public void Send <TClass>(BaseContainer <TClass> message)
        {
            byte[] messageBroadcast = ConvertToBytes(message.GetContainer());
            _sendQueue.Enqueue(messageBroadcast);

            if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0)
            {
                SendImpl();
            }
        }