public async Task <IActionResult> Register(RegisterVM model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new CSUser { UserName = model.Username, RealName = model.RealName }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent : false); await _userManager.AddToRoleAsync(user, "User"); if (user.UserName == "Admin") { await _userManager.AddToRoleAsync(user, "Administrator"); } _logger.LogInformation(3, "User created a new account with password. Set role user/"); return(RedirectToLocal(returnUrl)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public EndParameters(CSUser current, CSUser challenger, GameState state, bool play) { this.challenger = challenger; this.current = current; this.state = state; this.play = play; }
/// <summary> /// 获取指定BS逻辑ID的所有玩家 /// </summary> internal List <uint> GetUserSIDs(uint lid) { if (!this._lidToBID.TryGetValue(lid, out List <uint> bids)) { return(null); } if (bids.Count == 0) { return(null); } List <uint> sids = new List <uint>(); int count = bids.Count; for (int i = 0; i < count; i++) { ulong lbID = lid | ( ulong )bids[i] << 32; List <CSUser> users = this._lbIDToUsers[lbID]; int c2 = users.Count; for (int j = 0; j < c2; j++) { CSUser user = users[j]; if (!user.isConnected) { continue; } sids.Add(user.gsSID); } } return(sids); }
public void endGameState(CSUser user, CSUser challenger, GameState state, bool play) { me = user; if (dataGridViewGame.Rows.Count > 1) { dataGridViewGame.Rows[0].Cells[1].Value = me.Points.ToString(); dataGridViewGame.Rows[0].Cells[2].Value = me.NbParties.ToString(); dataGridViewGame.Rows[1].Cells[1].Value = challenger.Points.ToString(); dataGridViewGame.Rows[1].Cells[2].Value = challenger.NbParties.ToString(); toolStripStatusLabel1.Text = me + " : " + myState.ToString() + " (vs " + challenger.Login + ")"; reset(); playState(play); } if (state == GameState.DRAW) { log(Severiry.INFO, "Draw game !"); receiveMsgState(new CSUser("Game master"), "Draw game, well played both of you !"); } else if (state == GameState.WON) { log(Severiry.INFO, "Congratulation, You won !"); receiveMsgState(new CSUser("Game master"), "Congratulation '" + me.Login + "', you are the winner !"); } else { log(Severiry.INFO, "Bad played, You lost !"); receiveMsgState(new CSUser("Game master"), "Congratulation '" + challenger.Login + "', you are the winner !"); } }
public ErrorCode AddUser(CSUser user) { if (null == user) { return(ErrorCode.NullUser); } user.ResetPingTimer(); ulong un64ObjIndex = user.guid; if (string.IsNullOrEmpty(user.username)) { Logger.Error("invalid username"); return(ErrorCode.InvalidUserName); } if (!this.userGuidMap.TryAdd(un64ObjIndex, user)) { Logger.Error("add username fail"); return(ErrorCode.AddUserNameFailed); } if (!string.IsNullOrEmpty(user.nickname)) { this.nickNameMap.Add(user.nickname, user); } long timerID = CS.instance.AddTimer(user.CheckDbSaveTimer, 1000, true); //todo CCSCfgMgr::getInstance().GetCSGlobalCfg().dbSaveTimeSpace * 1000 user.timerID = timerID; return(ErrorCode.Success); }
private void deconnectionState() { timer1.Stop(); currentEffectTime = 0; if (myState != State.PLAYING_COMPUTER) { reset(); groupBoxGameBoard.Enabled = false; buttonQuitGame.Visible = false; buttonComputer.Enabled = true; dataGridViewGame.Rows.Clear(); } groupBoxListofPlayers.Visible = true; groupBoxReceivedR.Visible = true; groupBoxTchat.Visible = false; buttonConnect.Enabled = true; buttonComputer.Enabled = true; buttonLogin.Enabled = false; buttonRegister.Enabled = false; buttonDisconnect.Enabled = false; buttonAbortSent.Enabled = false; dataGridViewList.Rows.Clear(); dataGridViewRequests.Rows.Clear(); labelSentTo.Text = "..."; labelLog.Text = ""; me = new CSUser(ClientThread.DEFAULTNAME); myState = State.DECONNECTED; toolStripStatusLabel1.Text = me + " : " + myState.ToString(); }
/// <summary> /// 玩家请求加入房间 /// </summary> public ErrorCode OnGc2CsJoinRoom(NetSessionBase session, IMessage message) { Protos.GC2CS_JoinRoom request = (Protos.GC2CS_JoinRoom)message; Protos.CS2GC_JoinRoomRet response = ProtoCreator.R_GC2CS_JoinRoom(request.Opts.Pid); ulong gcNID = request.Opts.Transid; CSUser user = CS.instance.userMgr.GetUser(gcNID); if (user == null) { response.Result = Protos.Global.Types.ECommon.Failed; } else { CS.instance.roomMgr.Join(user, request.RoomID, () => { response.Result = Protos.Global.Types.ECommon.Success; user.Send(response); }, () => { response.Result = Protos.Global.Types.ECommon.Failed; user.Send(response); }); } return(ErrorCode.Success); }
private static void OnBuyChampion(NetSessionBase session, IMessage message, object[] args) { CSUser user = ( CSUser )args[0]; int moneyResult = ( int )args[1]; int diamonedResult = ( int )args[2]; int cid = ( int )args[3]; Protos.CS2GC_BuyChampionRet response = (Protos.CS2GC_BuyChampionRet)args[4]; Protos.DB2CS_BuyChampionRet dbResponse = (Protos.DB2CS_BuyChampionRet)message; if (dbResponse.Result == Protos.Global.Types.ECommon.Failed) { response.Result = Protos.CS2GC_BuyChampionRet.Types.Result.Failed; } else { user.money = moneyResult; user.diamoned = diamonedResult; user.champions.Add(cid); response.Result = Protos.CS2GC_BuyChampionRet.Types.Result.Success; response.Money = user.money; response.Diamoned = user.diamoned; response.Cids.AddRange(user.champions); } user.Send(response); }
/// <summary> /// 玩家请求创建房间 /// </summary> public ErrorCode OnGc2CsCreateRoom(NetSessionBase session, IMessage message) { Protos.GC2CS_CreateRoom request = (Protos.GC2CS_CreateRoom)message; Protos.CS2GC_CreateRoomRet response = ProtoCreator.R_GC2CS_CreateRoom(request.Opts.Pid); ulong gcNID = request.Opts.Transid; CSUser user = CS.instance.userMgr.GetUser(gcNID); if (user == null) { response.Result = Protos.Global.Types.ECommon.Failed; } else { if (user.isInBattle) { response.Result = Protos.Global.Types.ECommon.Failed; } else { response.Result = CS.instance.roomMgr.Create(user, request.NumTeam, request.NumPlayerPerTeam, out uint roomID) ? Protos.Global.Types.ECommon.Success : Protos.Global.Types.ECommon.Failed; response.RoomID = roomID; } } user.Send(response); return(ErrorCode.Success); }
private ErrorCode UserAskReconnectGame(CSGSInfo csgsInfo, uint gcNetID, string name, string passwd) { UserNetInfo netinfo = new UserNetInfo(csgsInfo.m_n32GSID, gcNetID); if (this.ContainsUser(netinfo)) { return(ErrorCode.InvalidNetState); } //需要从消息获取 const int sdkID = 0; UserCombineKey sUserCombineKey = new UserCombineKey(name, sdkID); if (!this.allUserName2GuidMap.TryGetValue(sUserCombineKey, out ulong guid)) { return(ErrorCode.NullUser); } CSUser pcUser = this.GetUser(guid); if (null == pcUser) { return(ErrorCode.NullUser); } GCToCS.Login login = new GCToCS.Login(); pcUser.OnOnline(netinfo, login, false, false, true); return(ErrorCode.Success); }
public SettingsModel(IConfiguration config, IHttpContextAccessor httpContextAccessor, UserManager <CStatUser> userManager) { _config = config; _userManager = userManager; Settings = CSSettings.GetCSSettings(_config, userManager); Settings.EquipProps = Settings.EquipProps.Select(e => { if (e.Attributes == null) { e.Attributes = ""; } return(e); }).ToList(); string UserId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Subject.Name; UserSettings = Settings.GetUser(UserId); if (UserSettings == null) { UserSettings = new CSUser(); UserSettings.EMail = UserId; UserSettings.ShowAllTasks = false; UserSettings.SendEquipText = false; UserSettings.SendStockText = false; UserSettings.SendTaskText = false; UserSettings.SendEMailToo = false; Settings.UserSettings.Add(UserSettings); } }
public bool Create(CSUser user, int numTeams, int numPlayerPerTeam, out uint roomID) { roomID = 0; //是否已在房间 if (this._userIDToBattleUser.ContainsKey(user.gcNID)) { return(false); } var room = RoomPool.Pop(this); room.Setup(numTeams, numPlayerPerTeam); BattleUser battleUser = new BattleUser(user.gcNID); if (!room.AddUser(battleUser)) { RoomPool.Push(room); return(false); } this._userIDToBattleUser[user.gcNID] = battleUser; this._userToRoom[user.gcNID] = room; this._idToRoom[room.id] = room; this.CheckRoom(room); roomID = room.id; return(true); }
public void receiveMsgHandler(CSUser user, string msg) { this.Invoke((MethodInvoker) delegate { receiveMsgState(user, msg); }); }
private void InsertNewUserToMysql(GCToCS.Login login, CSUser user) { if (user == null) { return; } CSToDB.ExeSQL_Call sqlCall = new CSToDB.ExeSQL_Call { Sql = $"insert account_user(id,cs_id,sdk_id,cdkey) values({user.guid},{CS.instance.csKernelCfg.unCSId},{login.Sdk},\'{login.Name}\');" }; this._cdkeyWrapper.EncodeAndSendToDBThread(sqlCall, ( int )CSToDB.MsgID.EExeSqlCall); string op = $"insert gameuser(obj_id,sdk_id,obj_cdkey, obj_register_time) values({user.guid},{login.Sdk},\'{login.Name}\',{user.userDbData.usrDBData.tRegisteUTCMillisec});" + $"insert gameuser_runne(user_id) values({user.guid});" + $"insert gameuser_guide(obj_id) values({user.guid});"; CSToDB.UpdateUser updateUser = new CSToDB.UpdateUser { Sqlstr = op, Guid = ( long )user.guid }; this._userCacheDBActiveWrapper.EncodeAndSendToDBThread(updateUser, ( int )CSToDB.MsgID.EUpdateUserDbcallBack); }
public void startGameHandler(CSUser user, bool beginer) { this.Invoke((MethodInvoker) delegate { lastState = myState; myState = State.PLAYING; dataGridViewRequests.Rows.Clear(); dataGridViewList.Rows.Clear(); groupBoxGameBoard.Enabled = true; groupBoxListofPlayers.Visible = false; groupBoxReceivedR.Visible = false; groupBoxTchat.Visible = true; labelSentTo.Text = "..."; labelLog.Text = ""; buttonAbortSent.Enabled = false; buttonComputer.Enabled = false; buttonLogin.Enabled = false; buttonRegister.Enabled = false; buttonQuitGame.Visible = true; toolStripStatusLabel1.Text = me + " : " + myState.ToString() + " (vs " + user.Login + ")"; dataGridViewGame.Rows.Add(new string[] { me.Login, me.Points.ToString(), me.NbParties.ToString() }); dataGridViewGame.Rows.Add(new string[] { user.Login, user.Points.ToString(), user.NbParties.ToString() }); playState(beginer); }); }
public void requestHandler(CSUser user) { this.Invoke((MethodInvoker) delegate { dataGridViewRequests.Rows.Add(new string[] { user.Login, "Accept", "Abort" }); }); }
protected override void endGameHandler(UserThread client, CSMessage msg) { try { CSUser challenger = (CSUser)msg.get(MessageType.USER); bool play = (bool)msg.get(MessageType.PLAY_GAME); Object gameStuff = (Object)msg.get(MessageType.GAME_STUFF); GameState state = GameState.LOST; if (msg.get(MessageType.WIN_GAME) != null) { client.ClientUser.win(); state = GameState.WON; } else if (msg.get(MessageType.DRAW_GAME) != null) { client.ClientUser.draw(); state = GameState.DRAW; } client.ClientUser.incrementParties(); if (view.isOpened()) { view.endGameHandler(client.ClientUser, challenger, state, play, gameStuff); } } catch (Exception e) { log(Severiry.ERROR, "Controller[EndGame] - " + e.Message); } }
/// <summary> /// 把玩家添加到暂存区 /// </summary> /// <param name="user">玩家</param> /// <param name="lid">BS的逻辑ID</param> /// <param name="sid">BS的SessionID</param> /// <param name="bid">战场ID</param> internal void Add(CSUser user, uint lid, uint sid, uint bid) { System.Diagnostics.Debug.Assert(!user.isInBattle, $"user:{user.gcNID} already in battle staging"); //记录BS sessionID user.EnterBattle(sid, lid, bid); this._lbIDToUsers.AddToList(lid | ( ulong )bid << 32, user); Logger.Log($"user:{user.gcNID} join staging. lid:{lid}, bid:{bid}"); }
public void stopGameHandler(CSUser user) { this.Invoke((MethodInvoker) delegate { stopGameState(); log(Severiry.INFO, "Player '" + user.Login + "' stopped the game !"); }); }
public void connectionHandler(CSUser user) { this.Invoke((MethodInvoker) delegate { me = user; connectionState(); }); }
public void loginHandler(CSUser user) { this.Invoke((MethodInvoker) delegate { me = user; logedState(); }); }
private void buttonAbortSent_Click(object sender, EventArgs e) { CSUser user = new CSUser(labelSentTo.Text); labelSentTo.Text = "..."; buttonAbortSent.Enabled = false; abort(user, true); }
/// <summary> /// Send a game response message to the server. /// </summary> /// <param name="user"></param> private void responseEvent(CSUser user) { CSMessage msg = new CSMessage(MessageType.CHALLENGING). add(MessageType.RESPONSE, true). add(MessageType.USER, user); process.send(msg); }
public ErrorCode OnUserOnline(CSUser csUser, UserNetInfo netInfo) { this.userNetMap.Add(netInfo, csUser); this.userOnlineMap.Add(csUser.guid, csUser); csUser.SetUserNetInfo(netInfo); Logger.Log($"add user netinfo({netInfo.gcNetID})"); return(ErrorCode.Success); }
private void receiveMsgState(CSUser user, string msg) { Color color = user.Equals(me) ? Color.Blue : user.Equals(new CSUser("Game master")) ? Color.DarkRed : Color.Green; richTextBoxMsg.SelectionColor = color; richTextBoxMsg.AppendText(user.Login + " [" + DateTime.Now.ToString("HH:mm") + "] - " + msg + "\n"); richTextBoxMsg.SelectionColor = richTextBoxMsg.ForeColor; }
private void UpdateUserNickNameToDB(CSUser user) { CSToDB.ChangeNickName changeNickName = new CSToDB.ChangeNickName { Nickname = user.nickname, Guid = ( long )user.guid }; this._cdkeyWrapper.EncodeAndSendToDBThread(changeNickName, ( int )CSToDB.MsgID.EChangeNickNameDbcall); }
public void addUser(CSUser user) { this.Invoke((MethodInvoker) delegate { dataGridViewUsers.Rows.Add(new string[] { user.Login, user.Points.ToString(), user.NbParties.ToString() }); }); }
public void newParty(CSUser user1, CSUser user2) { this.Invoke((MethodInvoker) delegate { dataGridViewParties.Rows.Add(new string[] { user1.Login, " ", user2.Login }); }); }
// // GET: /Project/ public ActionResult Index() { var mediator = new ProjectMediator(); CSUser user = SessionHelper.GetUserSession(); var projects = mediator.GetAllCompanyProjects(user.CompanyId); ViewBag.CompanyId = user.CompanyId; return(View(projects)); }
public void endGameHandler(CSUser user, CSUser challenger, GameState state, bool play, Object gameStuff) { this.Invoke((MethodInvoker) delegate { endParams = new EndParameters(user, challenger, state, play); setLastMove(gameStuff, 1); drawGame(1); }); }