/// <summary> /// 注册新的用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult AddUser(User user) { bool isAdd = UserMgr.AddUser(user); StateModel state = new StateModel(isAdd); if (!state.Status) { state.Message = "注册发生异常,请联系管理员!"; } return(Json(state)); }
private void InitUser(long uid, WebSocket socket, UserModel model) { if (handler == null || socket == null) { throw new Exception("InitUser null!~"); } var socketid = handler.connManager.GetId(socket); if (socketid > 0) { var user = UserMgr.AddUser(socketid, socket); user.uid = uid; user.name = model.GetUserName(uid.ToString()); } }
public void NotifyInConnectClient(ServerPacketData requestData) { var errorCode = UserMgr.AddUser(requestData.SessionID); if (errorCode != ERROR_CODE.NONE) { GameServer.MainLogger.Error($"Fail AddUser. NetSessionID: {requestData.SessionID}"); //TODO: 클라이언트에게 에러를 보낸다. 그리고 이 유저가 지정된 시간까지 나가지 않는 경우 제거하도록 한다. return; } GameServer.MainLogger.Debug($"AddUser. NetSessionID: {requestData.SessionID}"); return; }
public void Register(HttpContext context) { User user = new User(); user.UserId = context.Request["uid"]; user.Password = context.Request["pwd"]; user.Name = context.Request["name"]; user.Address = context.Request["address"]; bool isAdd = UserMgr.AddUser(user); StateModel state = new StateModel(isAdd); if (!state.Status) { state.Message = "注册发生异常,请联系管理员!"; } context.Response.Write(JsonConvert.SerializeObject(state)); }
public void Add(HttpContext context) { string name = context.Request["name"]; string pwd = context.Request["pwd"]; User user = new User(); user.Name = name; user.Pwd = pwd; bool res = UserMgr.AddUser(user); if (res) { context.Response.Write("true"); } else { context.Response.Write("false"); } }
public void RequestLogin(ServerPacketData packetData) { var sessionID = packetData.SessionID; var sessionIndex = packetData.SessionIndex; MainServer.MainLogger.Debug("로그인 요청 받음"); try { if (UserMgr.GetUser(sessionIndex) != null) { ResponseLoginToClient(ERROR_CODE.LOGIN_ALREADY_WORKING, packetData.SessionID); return; } var reqData = MessagePackSerializer.Deserialize <PKTReqLogin>(packetData.BodyData); var errorCode = UserMgr.AddUser(reqData.UserID, packetData.SessionID, packetData.SessionIndex); if (errorCode != ERROR_CODE.NONE) { ResponseLoginToClient(errorCode, packetData.SessionID); if (errorCode == ERROR_CODE.LOGIN_FULL_USER_COUNT) { NotifyMustCloseToClient(ERROR_CODE.LOGIN_FULL_USER_COUNT, packetData.SessionID); } return; } ResponseLoginToClient(errorCode, packetData.SessionID); MainServer.MainLogger.Debug("로그인 요청 답변 보냄"); } catch (Exception ex) { // 패킷 해제에 의해서 로그가 남지 않도록 로그 수준을 Debug로 한다. MainServer.MainLogger.Error(ex.ToString()); } }
/// <summary> /// 用户安全操作相关操作菜单 /// </summary> public static void LoginMenu() { while (true) { Console.WriteLine("请输入对应操作:"); Console.WriteLine("1-登录(默认)"); Console.WriteLine("2-注册"); string choice = Console.ReadLine(); if (choice == "2") { Console.WriteLine("****** 注册用户 ******"); User user = GetUserFromConsole(); bool addSuccess = UserMgr.AddUser(user); } else { Console.WriteLine("****** 登录 ******"); Console.Write("用户名:"); string uid = Console.ReadLine(); Console.Write("密码:"); string pwd = Console.ReadLine(); bool loginSuccess = UserMgr.Login(uid, pwd) != null; if (loginSuccess) { Console.Clear(); break; } else { Console.WriteLine("用户名或密码错误,请重新登录!!!"); } } } }
/// <summary> /// 添加登录人 /// </summary> /// <param name="loginUser"></param> public void AddUser(LoginUser loginUser) { UserMgr.AddUser(loginUser); }