Esempio n. 1
0
        private async void SendLoginInitAsync(ConnectionStateChangedEventArgs eventArgs)
        {
            await Task.Delay(1000);

            List <GeneralMessage> generalMessage = await _dataBaseManager.GetGeneralMessageAsync();

            List <PrivateMessage> privateMessages = await _dataBaseManager.GetPrivateMessageAsync();

            List <Event> events = await _dataBaseManager.GetEventAsync();

            await Task.Run(
                () =>
            {
                User user = _dataBaseManager.UserList.Find(u => u.Name == eventArgs.ClientName);
                var lrc   = new LoginResponseContainer(
                    new Response(ResponseType.Ok, eventArgs.EventLog.Text),
                    Collector.CollectGeneralChannel(user.Id, generalMessage),
                    Collector.CollectOnlineChannel(user, CheckUserList(_wsServer.UserOnlineList, _tcpServer.UserOnlineList), privateMessages),
                    Collector.CollectOfflineChannel(user, CheckUserList(_wsServer.UserOfflineList, _tcpServer.UserOfflineList), privateMessages),
                    Collector.CollectEventLog(user, events));
                _wsServer.Send(lrc, new PrivateAgenda(eventArgs.ClientName));
                _tcpServer.Send(lrc, new PrivateAgenda(eventArgs.ClientName));
            });
        }