/// <summary> /// 处理设备登录 /// </summary> /// <param name="loginInfo"></param> /// <param name="con"></param> /// <param name="db"></param> public void ProcessReqest(CmdHeader loginInfo, SocketConnection con, IClientRequest db) { con.Identity = loginInfo.Identity; con.SocketConnectType = SocketConnectType.DeviceSocket; SocketConnectionServerDispatcher.DicSockectConnection.AddOrUpdate(loginInfo.Identity, con, (key, old) => con); var loginDto = new DtoLogin { ImeiNo = loginInfo.Identity, RemoteIpEndPoint = con.ConnectSocket.RemoteEndPoint.ToString(), ServerIp = con.ConnectSocket.LocalEndPoint.ToString(), ServerOutIp = SocketConnectionServerDispatcher.ServerOutIpEndPort }; var res = db.DeviceLogin(loginDto); //con.StateData.BoundList = res.UsrClients; var loginBk = new LoginBk { CmdCode = 0xFF02, Identity = loginInfo.Identity, ServerId = SocketConnectionServerDispatcher.ServerId, TimeToken = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), ResultCode = res.Res }; //TODO 根据链接的多个服务器返回新的上位机地址 con.Send(loginBk.ToByteArray()); SocketConnection.ShowMsg(loginBk.ToString()); //var appconfig = CommCode.AppSettings("gettuiappid", "gettuiappkey", "gettuimasterkey"); //if (con.StateData.BoundList == null) return; //foreach (var usrClient in con.StateData.BoundList) //{ // CommCode.GeTuiMsg("设备通知", "设备" + con.Identity + "上线", appconfig[0], appconfig[1], appconfig[2], usrClient.ClientId, null); //} }
/// <summary> /// 处理用户单点登录 /// </summary> /// <param name="clientInfo"></param> /// <param name="con"></param> /// <param name="db"></param> public void ProcessReqest(ClientLogin clientInfo, SocketConnection con, IClientRequest db) { con.Identity = clientInfo.Identity; con.PhoneMac = clientInfo.PhoneMac; SocketConnection oldSocket; var loginBk = new LoginBk { CmdCode = 0xFF02, Identity = clientInfo.Identity, ServerId = SocketConnectionServerDispatcher.ServerId, //TimeToken = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), ResultCode = 1 }; con.Send(loginBk.ToByteArray()); if (SocketConnectionServerDispatcher.DicSockectConnection.TryGetValue(clientInfo.Identity, out oldSocket) && !oldSocket.PhoneMac.Equals(con.PhoneMac)) { loginBk.ResultCode = 4; oldSocket.Send(loginBk.ToByteArray()); //返回处理结果 } SocketConnectionServerDispatcher.DicSockectConnection.AddOrUpdate(clientInfo.Identity, con, (key, old) => con); SocketConnection.ShowMsg(clientInfo.ToString()); }