Beispiel #1
0
        /// <summary>
        /// 当设备或客户链接时,分配控制器
        /// </summary>
        void CreateThreadToCheckData()
        {
            m.DataLiveEvent += new EventManager.DataLiveHandler(DisposeControl);
            while (true)
            {
                Socket socket = null;
                cloud.cloudnet.socketslist.TryDequeue(out socket);
                if (socket != null)
                {
                    byte[] buf = new byte[1024 * 1024];

                    socket.Receive(buf);
                    Package package = IoT_Net.BytesToPackage(buf);

                    if (package.message == Messagetype.codeus)
                    {
                        PointCloudUserC userC = new PointCloudUserC(socket, package, cc, m);
                        UserC.Add(userC);

                        IPList iP = new IPList();
                        iP.ID = userC.ID;
                        iP.IP = socket.RemoteEndPoint.ToString();
                        cloud.IPmanager("Add", "UserList", iP);
                    }
                    else
                    {
                        if (package.message == Messagetype.ID)
                        {
                            PointCloudDeviceC deviceC = new PointCloudDeviceC(socket, package, m);
                            DeviceC.Add(deviceC);

                            IPList iP = new IPList();
                            iP.ID = deviceC.ID;
                            iP.IP = socket.RemoteEndPoint.ToString();
                            cloud.IPmanager("Add", "DeviceList", iP);
                        }
                    }
                    m.SimulateNewIPLEvent(cloud.DeviceList);
                }
                Thread.Sleep(100);
            }
        }
Beispiel #2
0
        public void IPmanager(string DoType, string Listname, IPList iP)
        {
            switch (DoType)
            {
            case "Add": switch (Listname)
                {
                case "UserList": Data.UserList.Add(iP); break;

                case "DeviceList": Data.DeviceList.Add(iP); break;
                }
                break;

            case "Remove": switch (Listname)
                {
                case "UserList": Data.UserList.Remove(iP); break;

                case "DeviceList": Data.DeviceList.Remove(iP); break;
                }
                break;
            }
        }