示例#1
0
        public void ConnectedPeersTracker()
        {
            //while (true)
            //{
            //    foreach (var connPeers in virtualRouterHost.GetConnectedPeers())
            //    {
            //        listBox1.Items.Add(connPeers.MacAddress.ToString());
            //    }
            //    Thread.Sleep(200);
            //    listBox1.Items.Clear();
            //    //listBox1.
            //}
            var peers = virtualRouterHost.GetConnectedPeers();

            while (true)
            {
                label6.Text = "Peers Connected (" + peers.Count().ToString() + "):";
                foreach (var p in peers)
                {
                    listBox1.Items.Add(p.MacAddress.ToString());
                }
                Thread.Sleep(200);
                listBox1.Items.Clear();
            }
        }
示例#2
0
文件: Form1.cs 项目: spyrax10/WIFI
        private void ConnectedPeersTracker()
        {
            string time = DateTime.Now.ToLongTimeString();

            try
            {
                //if (virtualRouterHost.IsStarted())
                //if (bgthread.IsAlive == true)
                while (true)
                {
                    var peers = virtualRouterHost.GetConnectedPeers();
                    label6.Text = peers.Count().ToString();
                    //mac2();
                    foreach (var p in peers)
                    {
                        if (!this.duplicate(p))
                        {
                            string mac = p.MacAddress.ToString();
                            listBox1.Items.Add(mac);
                            //gVIp.Rows.Add(mac, "ip", time);
                            lblStat.Text = "mi konek si: " + mac;
                        }
                    }
                    listBox1.Items.Remove(peers);

                    //   break;
                    // mac2();
                    Thread.Sleep(200);
                    listBox1.Items.Clear();
                    lblStat.ResetText();
                }
                //       else
                //     {
                //       label6.Text = "0";
                // }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "  conectt");
            }

            //while (true)
            //{
            //    foreach (var connPeers in virtualRouterHost.GetConnectedPeers())
            //    {
            //        listBox1.Items.Add(connPeers.MacAddress.ToString());
            //    }
            //    Thread.Sleep(200);
            //    listBox1.Items.Clear();
            //    //listBox1.
            //}
        }
示例#3
0
        public async void ConnectedPeersTracker()
        {
            var clientCourseId = new HttpClient();
            HttpResponseMessage responseCourseId = await clientCourseId.GetAsync("http://localhost:43719/api/lessonTime/dateOnly/" + dateOnly + "/hourOnly/" + hourOnly);

            string strCourseId = await responseCourseId.Content.ReadAsStringAsync();

            int courseId = int.Parse(strCourseId);

            var peers = virtualRouterHost.GetConnectedPeers();

            while (true)
            {
                //label6.Text = "Peers Connected (" + peers.Count().ToString() + "):";
                foreach (var p in peers)
                {
                    if (courseId != -1)
                    {
                        var clientId = new HttpClient();
                        HttpResponseMessage responseId = await clientId.GetAsync("http://localhost:43719/api/member/Iduser/" + Mail + "/Idpassword/" + Password);

                        string stringId = await responseId.Content.ReadAsStringAsync();

                        int lecturerId = int.Parse(stringId);



                        var clientStudentId = new HttpClient();
                        HttpResponseMessage responseStudentId = await clientStudentId.GetAsync("http://localhost:43719/api/member/macAddress/" + p.MacAddress.ToString());

                        string strStudentId = await responseStudentId.Content.ReadAsStringAsync();

                        int studentId = int.Parse(strStudentId);

                        var clientExistStudent = new HttpClient();
                        HttpResponseMessage responseExistStudent = await clientExistStudent.GetAsync("http://localhost:43719/api/courseStudent/CheckIfExists/studentId/" + studentId + "/courseId/" + courseId);

                        string strExistStudent = await responseExistStudent.Content.ReadAsStringAsync();

                        bool existStudent = bool.Parse(strExistStudent);

                        if (existStudent)
                        {
                            var clientLessonTimeId = new HttpClient();
                            HttpResponseMessage responseLessonTimeId = await clientLessonTimeId.GetAsync("http://localhost:43719/api/lessonTime/date/" + dateOnly + "/hour/" + hourOnly + "/Lecture/" + lecturerId);

                            string strLessonTimeId = await responseLessonTimeId.Content.ReadAsStringAsync();

                            int lessonTimeId = int.Parse(strLessonTimeId);

                            var clientLessonTime = new HttpClient();
                            HttpResponseMessage responseLessonTime = await clientLessonTime.GetAsync("http://localhost:43719/api/lessonTime/GetLessonTime/" + lessonTimeId);

                            string strLessonTime = await responseLessonTime.Content.ReadAsStringAsync();

                            string lessonTime = strLessonTime;
                            if (lessonTime.Contains("\""))
                            {
                                lessonTime = lessonTime.Substring(1, lessonTime.Length - 2);
                            }



                            var client1 = new HttpClient();
                            client1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
                            var requestContent1 = new FormUrlEncodedContent(new[] {
                                new KeyValuePair <string, string>("StudentId", studentId.ToString()),
                                new KeyValuePair <string, string>("LessonId", lessonTimeId.ToString()),
                                new KeyValuePair <string, string>("CheckTimeStart", TimeSpan.Parse(hourOnly).ToString()),
                                new KeyValuePair <string, string>("CheckTimeEnd", lessonTime),
                            });
                            HttpResponseMessage response1 = await client1.PostAsync(
                                "http://localhost:43719/api/lessonAttending",
                                requestContent1);
                        }
                    }
                }
                Thread.Sleep(200);
            }
        }