public void Operation(MainRequest chatData)
        {
            var        data    = chatData as PrivateChatMessageModel;
            ChatModule newChat = new PrivateChat();

            newChat.AddClient(_userClient);

            List <IClientModel> clients = new List <IClientModel>();

            clients.Add(_userClient);

            foreach (var clientName in data.lsUsers)
            {
                if (_allChatDetails.IsClientExist(clientName))
                {
                    IClientModel client = _allChatDetails.GetClientByName(clientName);
                    clients.Add(client);
                    newChat.AddClient(client);
                }
            }
            if (!_allChatDetails.IsExistChatWithSamePeaple(clients, ChatType.Private))
            {
                _allChatDetails.AddChat(newChat);
            }
        }
Ejemplo n.º 2
0
        public void Operation(MainRequest chatData)
        {
            var       data         = chatData as GroupChatMessageModel;
            GroupChat newGroupChat = new GroupChat(data.GroupName);

            List <IClientModel> clients = new List <IClientModel>();

            clients.Add(_userClient);
            if (data.lsUsers.Count == 0)
            {
                return;
            }
            newGroupChat.AddManager(_userClient);
            newGroupChat.AddClient(_userClient);
            foreach (var clientName in data.lsUsers)
            {
                if (_allChatDetails.IsClientExist(clientName))
                {
                    IClientModel client = _allChatDetails.GetClientByName(clientName);
                    clients.Add(client);
                    newGroupChat.AddClient(client);
                }
            }

            if (!_allChatDetails.IsExistChatWithName(data.GroupName))
            {
                _allChatDetails.AddChat(newGroupChat);
                _containerInterfaces.Logger.LogInformation($"Group {data.GroupName} added");
            }
        }
Ejemplo n.º 3
0
        public void Operation(MainRequest chatData)
        {
            var         data         = chatData as GroupChatMessageModel;
            GroupChat   newGroupChat = new GroupChat(data.GroupName);
            ClientModel senerClient  = _allChatDetails.GetClientByName(Name);

            List <ClientModel> clients = new List <ClientModel>();

            clients.Add(senerClient);
            if (data.lsUsers.Count == 0)
            {
                return;
            }
            newGroupChat.AddManager(senerClient);
            newGroupChat.AddClient(senerClient);
            foreach (var clientName in data.lsUsers)
            {
                if (_allChatDetails.IsClientExist(clientName))
                {
                    ClientModel client = _allChatDetails.GetClientByName(clientName);
                    clients.Add(client);
                    newGroupChat.AddClient(client);
                }
            }

            if (!_allChatDetails.IsExistChatWithName(data.GroupName))
            {
                _allChatDetails.AddChat(newGroupChat);
                Console.WriteLine($"Group {data.GroupName} added");
            }
        }
        public void Run()
        {
            string name = _responseHandler.GetResponse(_client);

            if (!_allChatDetails.IsClientExist(name))
            {
                _allChatDetails.AddClient(new ClientModel(name, _client));
            }
            Console.WriteLine($"Client with name : {name} connected to server");

            var clientName = GetClient(name);

            if (clientName != null)
            {
                if (!clientName.Connected)
                {
                    var globalChat = _allChatDetails.GetAllChatByType(ChatType.Globaly)[0];
                    globalChat.RemoveClient(clientName);
                    globalChat.AddClient(clientName);
                }

                _userClient                     = clientName;
                _userClient.Client              = _client;
                _userClient.Connected           = true;
                _userClient.LastStatusConnected = true;
            }
            else
            {
                var globalChat = _allChatDetails.GetAllChatByType(ChatType.Globaly)[0];
                _userClient = new ClientModel(name, _client);
                globalChat.AddClient(_userClient);
            }
            //_userClient.CurrentConnectChat = _allChatDetails.GetAllChatByType(ChatType.Globaly)[0];

            //SendToAll($"user {_userClient.Name} connect to chat");


            ListenThread = new Thread(() =>
            {
                ListenReciveMesages();
            });
            ListenThread.Start();
        }
Ejemplo n.º 5
0
        private void StartClientConnection()
        {
            string name = _containerInterfaces.ResponseHandler.GetResponse(_client);

            if (!_allChatDetails.IsClientExist(name))
            {
                _userClient = new ClientModel(name, _client);
                _allChatDetails.AddClient(_userClient);
                var globalChat = _allChatDetails.GetAllChatByType(ChatType.Globaly)[0];
                globalChat.AddClient(_userClient);
            }
            else
            {
                _userClient = _allChatDetails.GetClientByName(name);
            }
            _containerInterfaces.Logger.LogInformation($"Client with name : {name} connected to server");

            _userClient.Client    = _client;
            _userClient.Connected = true;
        }