コード例 #1
0
        private void GetDeviceList()
        {
            var manageList = (from item in SocketServer.WebSocket.devicePool
                              select item.Value).ToList();

            Response.Write(manageList.ToJson());
            Response.End();
            json = null;
        }
コード例 #2
0
        private void GetAllSocketList()
        {
            var manageList = (from item in TcpServer.WebSocketHelper.clientPool
                              select new { id = item.Value.Name, handle = item.Value.handle.ToString() }).ToList();

            Response.Write(manageList.ToJson());
            Response.End();
            json = null;
        }
コード例 #3
0
        private void GetManageList()
        {
            var manageList = (from item in SocketServer.WebSocket.manageInfoPool
                              select new {
                                  onLineTime = item.Value.onLineTime,
                                  userName=item.Value.userName,
                                  handle=item.Key.Handle.ToString(),
                                  ip=item.Key.RemoteEndPoint.ToString()
                              }
                            ).ToList();

            Response.Write(manageList.ToJson());
            Response.End();
            json = null;
        }
コード例 #4
0
ファイル: WebSocket.cs プロジェクト: WangxuHub/SocketPost
        private void DeviceGoOnLine()
        {
            string deviceSN = socketContext.GetJsonValue("DeviceSN");
            DeviceInfo clientInfo = new DeviceInfo()
            {
                deviceSN=deviceSN,
                onLineTime=DateTime.Now
            };

            devicePool.Add(curClientSocket,clientInfo);

            mJsonResult json = new mJsonResult()
            {
                success = true,
                msg=string.Format("上线成功,上线时间:{0}",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                clientPostType = "retDeviceGoOnLine"
            };

            SocketMessage sm = new SocketMessage()
            {
                Message = json.ToJson(),
                SendToClients=new Dictionary<Socket,ClientInfo>(){{curClientSocket,null}}
            };
            msgPool.Add(sm);

            //设备上线 推送给所有管理页面
            GetOnlineDeviceList();
        }
コード例 #5
0
ファイル: WebSocket.cs プロジェクト: WangxuHub/SocketPost
        private void ManageGoOnLine()
        {
            string userName = socketContext.GetJsonValue("userName");
            ManageInfo clientInfo = new ManageInfo()
            {
                userName = userName,
                onLineTime = DateTime.Now
            };

            manageInfoPool.Add(curClientSocket, clientInfo);

            mJsonResult json = new mJsonResult()
            {
                success = true,
                msg = string.Format("上线成功,上线时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                clientPostType = "retManageGoOnLine"
            };

            SocketMessage sm = new SocketMessage()
            {
                Message = json.ToJson(),
                SendToClients = new Dictionary<Socket, ClientInfo>() { { curClientSocket, null } }
            };
            msgPool.Add(sm);
        }
コード例 #6
0
ファイル: WebSocket.cs プロジェクト: WangxuHub/SocketPost
        private void GetOnlineManageList()
        {
            var manageList = (from item in manageInfoPool
                              select item.Value).ToList();

            mJsonResult json = new mJsonResult()
            {
                success = true,
                rows = manageList,
                clientPostType = "retGetOnlineManageList"
            };

            //推送给所有连接的管理页面
            Dictionary<Socket, ClientInfo> sendto = (
                from a in manageInfoPool
                select new KeyValuePair<Socket, ClientInfo>(a.Key, null)
                ).ToDictionary(key => key.Key, value => value.Value);

            SocketMessage sm = new SocketMessage()
            {
                Message = json.ToJson(),
                SendToClients = sendto
            };
            msgPool.Add(sm);
        }