public void AddPoker(Poker poker) { if (poker == null || String.IsNullOrWhiteSpace(poker.NickName)) return; lock (pokerNameDic) { if (pokerNameDic.ContainsKey(poker.NickName)) pokerNameDic[poker.NickName] = poker; else pokerNameDic.Add(poker.NickName, poker); } }
protected void btnLogin_Click(object sender, EventArgs e) { var room = Lobby.Instance.GetRoom(tbRoomName.Text); var poker = room.GetPoker(tbNickName.Text); if (poker == null) poker = new Poker { NickName = tbNickName.Text }; if (!String.IsNullOrEmpty(tbRoomPwd.Text)) { if (!String.IsNullOrEmpty(room.Password) && room.Password != tbRoomPwd.Text) { ScriptManager.RegisterStartupScript(this, typeof(Login), "", "alert('房间密码不正确\\n无法作为管理员登录')", true); return; } room.Password = tbRoomPwd.Text; poker.IsRoomAdmin = true; } room.AddPoker(poker); SessionController.SetRoomName(this, room.Name); SessionController.SetPokerName(this, poker.NickName); SessionController.SetToken(this, ""); if (poker.IsRoomAdmin) Response.Redirect("AdminPokerPlay.aspx"); else Response.Redirect("PokerPlay.aspx"); }