Example #1
0
        public void Analysis(DataPackage data)
        {
            Thread tdAnalysis = new Thread(delegate ()
            {
                short type;
                byte[] bType = new byte[2];

                bType[0] = data.Data[0];
                bType[1] = data.Data[1];
                type = BitConverter.ToInt16(bType, 0);

                switch (type)
                {
                    case 1:            //信息
                        Message message = new Message(data.Data);
                        message.Send();
                        break;
                    case 2:            //登陆
                        AccountLogin accountLogin = new AccountLogin(data);
                        if (accountLogin.Login())
                        {
                            accountLogin.AddToOnlineUserList();
                            Data_BLL data_BLL = new Data_BLL();
                            data_BLL.SendAllMessage(accountLogin.loginData);
                        }
                        accountLogin.Respect();
                        break;
                    case 3:         //账号申请
                        AccountRequest accountRequest = new AccountRequest(data);
                        accountRequest.Respect();
                        break;
                }
            });
            tdAnalysis.Start();
        }
Example #2
0
        static public void ActiveService()
        {
            Thread tdChattingService_NO1 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
                
            });
            Thread tdChattingService_NO2 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO3 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO4 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO5 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });

            Thread tdHeartBeat = new Thread(delegate ()
            {
                HeartBeat();
                Thread.Sleep(TimeSpan.FromSeconds(5));
            });

            tdChattingService_NO1.Start();
            tdChattingService_NO2.Start();
            tdChattingService_NO3.Start();
            tdChattingService_NO4.Start();
            tdChattingService_NO5.Start();

            tdHeartBeat.Start();
        }
Example #3
0
        static public void ActiveService()
        {
            Thread tdService = new Thread(delegate ()
            {
                GetClient getClient = new GetClient();
                while (true)
                {
                    TcpClient tcpClient = getClient.Get();

                    Thread tdClientService = new Thread(delegate ()
                    {
                        TcpClient tcpUser = tcpClient;

                        try
                        {
                            Data_BLL bll = new Data_BLL();
                            while (true)
                            {
                                Receiver receiver = new Receiver();
                                bll.Analysis(receiver.ReceiveData(tcpUser));
                            }
                        }
                        catch
                        {
                            //[未升级] 从已登录用户中删除
                            lock (Data.Data.ArrOnlineUsers)
                            {
                                ArrayList arrTemp = new ArrayList();
                                for (int i = 0; i < Data.Data.ArrOnlineUsers.Count; i++)
                                {
                                    OnlineUserProperties onlineUser = (OnlineUserProperties)Data.Data.ArrOnlineUsers[i];
                                    if (onlineUser.Client != tcpUser)
                                        arrTemp.Add(Data.Data.ArrOnlineUsers[i]);
                                }
                                Data.Data.ArrOnlineUsers = arrTemp;
                            }
                        }
                    });
                    tdClientService.Start();
                    ThreadPool.ArrServiceThreads.Add(tdClientService);
                }
            });
            tdService.Start();
        }