예제 #1
0
        public void Thubai()
        {
            ServerResponse response = new ServerResponse(ServerResponseType.FinishExam, null);

            foreach (Socket item in ListClient)
            {
                item.Send(response.Serialize());
            }
        }
예제 #2
0
        public void SendListStudent(List <Student> students)
        {
            ServerResponse response = new ServerResponse(ServerResponseType.SendListStudentExcel, students);

            byte[] buff = response.Serialize();
            foreach (Socket item in ListClient)
            {
                item.Send(buff);
            }
        }
예제 #3
0
        public void StartExam(string time)
        {
            ServerResponse response = new ServerResponse(ServerResponseType.BeginExam, time);

            byte[] buff = response.Serialize();
            foreach (Socket item in ListClient)
            {
                item.Send(buff);
            }
        }
예제 #4
0
        public void SendThoiGianThi(string timeexam)
        {
            ServerResponse response = new ServerResponse(ServerResponseType.SendThoiGianThi, timeexam);

            byte[] buff = response.Serialize();
            foreach (Socket item in ListClient)
            {
                item.Send(buff);
            }
        }
예제 #5
0
        public void SendMonThi(string monthi)
        {
            ServerResponse response = new ServerResponse(ServerResponseType.SendMonThi, monthi);

            byte[] buff = response.Serialize();
            foreach (Socket item in ListClient)
            {
                item.Send(buff);
            }
        }
예제 #6
0
        public void SendmessageAll(string mess)
        {
            ServerResponse response = new ServerResponse(ServerResponseType.SendMessage, mess);

            byte[] buff = response.Serialize();
            foreach (Socket item in ListClient)
            {
                item.Send(buff);
            }
        }
예제 #7
0
        public void DisconnectAll()
        {
            foreach (Socket item in ListClient)
            {
                ServerResponse response = new ServerResponse(ServerResponseType.DisconnectAll, null);
                item.Send(response.Serialize());
            }

            ListClient.Clear();
            maytinhInfoManager.DisconnectAll();
        }
예제 #8
0
        public void PhatDe(List <string> dsDeThi)
        {
            if (dsDeThi.Count == 0)
            {
                return;
            }

            List <FileContainer> listfiledetai = new List <FileContainer>();

            foreach (string item in dsDeThi)
            {
                listfiledetai.Add(new FileContainer(item, this.clientpath));
            }

            if (dsDeThi.Count == 1)
            {
                FileContainer dethi = listfiledetai[0];
                foreach (Socket clientsock in ListClient)
                {
                    ServerResponse response = new ServerResponse(ServerResponseType.PhatDe, dethi);
                    clientsock.Send(response.Serialize());
                }
            }

            if (dsDeThi.Count > 1)
            {
                int soluongde = dsDeThi.Count;
                int detruoc   = 0;
                int desau     = 0;
                foreach (Socket item in ListClient)
                {
                    do
                    {
                        Random rd = new Random();
                        desau = rd.Next(0, soluongde);
                    } while (detruoc == desau);
                    detruoc = desau;
                    FileContainer  dethi    = listfiledetai[desau];
                    ServerResponse response = new ServerResponse(ServerResponseType.PhatDe, dethi);
                    item.Send(response.Serialize());
                }
            }
        }