public static void ChangeInviteAllow(Message Message, PubgSession Session) { var Callback = new Message(-Message.Identifier, null, true); if (Session.IsAuthenticated) { if (Session.Player.InviteAllow == null) { Session.Player.Profile.InviteAllow = "none"; } else { if (Session.Player.InviteAllow == "all") { Session.Player.Profile.InviteAllow = "none"; } else { Session.Player.Profile.InviteAllow = "all"; } } Callback.SetResult(Result: Session.Player.InviteAllow); } else { Callback.SetResult(Error: "This nagger is not authenticated."); } Session.Client.SendMessage(Callback); }
public void Add(PubgSession session, string body, int grounpId, int userId) { bool result = CheckGrounpCount(grounpId); DataResult dataResult = new DataResult(); if (result) { string sql = "insert into grounp_user(grounp_id,user_id) " + "values('" + grounpId + "','" + userId + "')"; int count = MySqlExecuteTools.AddOrUpdate(sql); if (count > 0) { dataResult.result = 0; dataResult.resean = "组队成功"; } else { dataResult.result = 1; dataResult.resean = "操作失败,请重试."; } } else { dataResult.result = 1; dataResult.resean = "该队用户已满,请重试."; } session.Send(GetSendData(dataResult, body)); }
/// <summary> /// Authenticates to the provider using the specified parameters. /// </summary> /// <param name="Provider">The provider.</param> /// <param name="Ticket">The ticket.</param> /// <param name="Username">The username.</param> /// <param name="Password">The password.</param> /// <param name="PlayerNetId">The player net identifier.</param> /// <param name="CountryCode">The country code.</param> /// <param name="Version">The version.</param> public async Task<bool> Authenticate(PubgSession Session, string Provider, string Ticket, string Username, string Password, string PlayerNetId, string CountryCode, string Version) { if (Provider == "bro") { Console.WriteLine("[*] Login with Bro !"); Session.Player = await this.Server.Players.Get(Username, Password); if (Session.Player != null) { return true; } } else if (Provider == "steam") { // Not implemented yet. } else if (Provider == "outer") { // Not implemented yet. } else if (Provider == "xbox") { // How ? } return false; }
/// <summary> /// Called when the WebSocket connection used in a session has been established. /// </summary> protected override async void OnOpen() { Logging.Info(this.GetType(), " - " + string.Join(" ", this.Context.QueryString.ToString().Split('&'))); string Provider = this.Context.QueryString.Get("provider"); string Ticket = this.Context.QueryString.Get("ticket"); string Username = this.Context.QueryString.Get("id"); string Password = this.Context.QueryString.Get("password"); string PlayerId = this.Context.QueryString.Get("playerNetId"); string Country = this.Context.QueryString.Get("cc"); string Version = this.Context.QueryString.Get("clientGameVersion"); string FullVersion = this.Context.QueryString.Get("fullClientGameVersion"); var PubgSession = new PubgSession(this); if (this.Proxy.Sessions.TryAdd(PubgSession)) { PubgSession.Player = new Player { Username = Username, Password = Password }; PubgSession.ConnectToOfficialServer(this.Context.RequestUri.PathAndQuery); } else { Logging.Warning(this.GetType(), "At OnOpen(), TryAdd(PubgSession) == false, aborting."); } }
//public void AddGrounp(PubgSession session, string body, string grounpName,string playerTime, string userId,string area="shanxi") //{ // Logger.InfoFormat("创建队:{0}", grounpName); // DataResult dataResult = new DataResult(); // string sql = "select * from grounp where userId = @userId"; // List<Grounp> result = MySqlExecuteTools.GetObjectResult<Grounp>(sql, // new MySqlParameter[] { new MySqlParameter("@userId", userId) }); // if(result.Count>= createGrounpCount) // { // dataResult.result = 1; // dataResult.resean = "您的权限最多创建"+ createGrounpCount + "个分队,请检查后重试。"; // session.Send(GetSendData(dataResult, body)); // return; // } // sql = "select * from grounp where name = @name and userId = @userId"; // result = MySqlExecuteTools.GetObjectResult<Grounp>(sql, // // new MySqlParameter[] { new MySqlParameter("@name", roomName), new MySqlParameter("@area", room.area.Trim())}); // new MySqlParameter[] { new MySqlParameter("@name", grounpName), new MySqlParameter("@userId", userId) }); // if (result.Count >0) // { // dataResult.result = 1; // dataResult.resean = "队名称已存在,请检查后重试。"; // } // else // { // //创建房间 // sql = "insert into grounp(name,runState,playerTime,area,userId) " + // "values('" + grounpName + "','-1','" + playerTime + "','" + area + "','" + userId + "')"; // long roomid = MySqlExecuteTools.GetAddID(sql); // if(roomid!=-1) // { // //创建房间 // CreateRoom(roomCount, roomid); // dataResult.result = 0; // dataResult.data = null; // } // else // { // dataResult.result = 1; // dataResult.data ="创建失败,请重试!"; // } // } // if(dataResult.result == 0) // { // joinRoomDao.GetAllRoom(); // } // session.Send(GetSendData(dataResult, body)); //} /// <summary> /// Delete /// </summary> /// <param name="session"></param> /// <param name="body"></param> /// <param name="id">roomid</param> /// <param name="userId">用户id</param> //public void DeleteGrounp(PubgSession session, string body, string grounpId) //{ // DataResult dataResult = new DataResult(); // //查询能否删除 // List<Room> roomList = SearchRoomListByGrounp(grounpId); // if(roomList==null || roomList.Count==0) // { // dataResult.result = 1; // dataResult.resean = "非法操作,无法进行删除。"; // session.Send(GetSendData(dataResult, body)); // return; // } // foreach(Room item in roomList) // { // List<Room_User> roomUserList = SearchSingleGrounpCommon(item.id.ToString()); // if (roomUserList.Count > 0) // { // dataResult.result = 1; // dataResult.resean = "该房间下存在用户,无法进行删除。"; // session.Send(GetSendData(dataResult, body)); // return; // } // } // //开始删除队信息 // string sql = "delete from grounp where id = @grounpId"; // MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@grounpId", grounpId) }); // dataResult.result = 0; // //删除房间的相关数据 // DeleteRoom(grounpId); // if (dataResult.result == 0) // { // joinRoomDao.GetAllRoom(); // } // session.Send(GetSendData(dataResult, body)); //} /// <summary> /// 更新房间 /// </summary> /// <param name="session"></param> /// <param name="body"></param> /// <param name="room"></param> public void UpdateGrounp(PubgSession session, string body, string grounpId, string grounpName, string checkCode, string playerTime) { DataResult dataResult = new DataResult(); Grounp p = SearchGrounpDao.GetGrounpById(grounpId); if (p != null && p.runState == 0) { dataResult.result = 1; dataResult.resean = "游戏运行中,无法修改游戏。"; session.Send(GetSendData(dataResult, body)); return; } //更新队 string sql = "update grounp set name = '" + grounpName + "', playerTime = '" + playerTime + "', checkCode = '" + checkCode + "', remainTime = '" + (int.Parse(playerTime) * 60) + "' where id = @grounpId"; MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@grounpId", grounpId) }); //更新分队信息 dataResult.result = 0; session.Send(GetSendData(dataResult, body)); }
public void CheckCode(PubgSession session, string body, string code, string userId, string userType, string deviceUniqueIdentifier, string plat, string system) { string sql = "select * from code where name = @name and userType = @userType"; List <CodeModel> result = MySqlExecuteTools.GetObjectResult <CodeModel>(sql, new MySqlParameter[] { new MySqlParameter("@name", code), new MySqlParameter("@userType", userType) }); DataResult dataResult = new DataResult(); //不存在 if (result.Count == 0) { dataResult.result = 1; dataResult.resean = "授权码输入有误,请重试!"; } else { CheckCountOrDateTime(result[0], dataResult, deviceUniqueIdentifier, plat, system, userId); } //save machine if (dataResult.result == 0) { SaveMachineCode(result[0], deviceUniqueIdentifier, plat, system, userId); } session.Send(GetSendData(dataResult, body)); }
public void SearchSingleRoom(PubgSession session, string body, string roomId) { Logger.InfoFormat("查询room下的user:{0}", roomId); DataResult dataResult = new DataResult(); dataResult.result = 0; dataResult.data = GetUserList(SearchSingleGrounpCommon(roomId)); session.Send(GetSendData(dataResult, body)); }
public void SearchSingleGrounp(PubgSession session, string body, string grounpId, string userId) { Logger.InfoFormat("查询单队下的房间:{0}", grounpId); DataResult dataResult = new DataResult(); dataResult.result = 0; dataResult.data = SearchRoomListByGrounp(grounpId, userId); session.Send(GetSendData(dataResult, body)); }
/// <summary> /// Called when the <see cref="T:WebSocketSharp.WebSocket" /> used in a session receives a message. /// </summary> /// <param name="Args">A <see cref="T:WebSocketSharp.MessageEventArgs" /> that represents the event data passed to /// a <see cref="E:WebSocketSharp.WebSocket.OnMessage" /> event.</param> protected override void OnMessage(MessageEventArgs Args) { if (Args.IsPing) { return; } Message Message = new Message(Args.Data); string ClassName = (string) Message.Parameters[1]; string MethodName = (string) Message.Parameters[2]; foreach (object Parameter in Message.Parameters.Skip(1)) { Console.WriteLine(" - " + Parameter + " #" + Message.Parameters.IndexOf(Parameter) + "."); } if (string.IsNullOrEmpty(ClassName) == false && string.IsNullOrEmpty(MethodName) == false) { Type Class = Type.GetType("PlayerUnknown.Lobby.Services.Api." + ClassName); if (Class != null) { MethodInfo Method = Class.GetMethod(MethodName, BindingFlags.Static | BindingFlags.Public); if (Method != null) { PubgSession Session = this.Server.Sessions.Get(this.ID); if (Session != null) { Method.Invoke(null, new object[] { Message, Session }); } else { Lobby.Log.Warning(this.GetType(), "PubgSession == null at OnMessage(Args)."); } } else { Lobby.Log.Warning(this.GetType(), "Method(" + MethodName + ") == null at OnMessage(Args)."); } } else { Lobby.Log.Warning(this.GetType(), "Class(" + ClassName + ") == null at OnMessage(Args)."); } } else { Lobby.Log.Warning(this.GetType(), "Message.IsValid != true at OnMessage(Args)."); } Console.WriteLine("--------------------------"); }
public static void Invalidate(PubgSession Session, string Class) { var Message = new Message(0, null, "ClientApi", "Invalidate"); Message.Parameters.Add(Session.Account.AccountId); Message.Parameters.Add("client." + Class); Message.Parameters.Add(null); Message.Parameters.Add(null); Session.Client.SendMessage(Message); }
public void StartSendChatMessage(string content, string userName, PubgSession session) { Dictionary <string, string> _dic = new Dictionary <string, string>(); _dic.Add("time", TimeUtils.GetCurrentFormatTime()); _dic.Add("content", content); _dic.Add("name", userName); string resultJson = Utils.CollectionsConvert.ToJSON(_dic); string data = "SendMessage" + Constant.START_SPLIT + resultJson + "\r\n"; session.Send(data); }
public static void GetActivatedEvents(Message Message, PubgSession Session) { var Callback = new Message(-Message.Identifier, null, true); if (Session.IsAuthenticated) { Callback.SetResult(Result: new JArray()); } else { Callback.SetResult(Error: "This nagger is not authenticated."); } Session.Client.SendMessage(Callback); }
public static void GetUserMatchState(Message Message, PubgSession Session) { var Callback = new Message(-Message.Identifier, null, true); if (Session.IsAuthenticated) { Callback.SetResult(Result: 3); } else { Callback.SetResult(Error: "This f****t is not authenticated."); } Session.Client.SendMessage(Callback); }
public void SearchAllGrounp(PubgSession session, string body, string keyName, string userId, string userType) { Logger.InfoFormat("查询所有的游戏:{0}", keyName); List <Grounp> result = null; if (keyName.Equals("-1")) { string sql = "select * from grounp ORDER BY id DESC"; result = MySqlExecuteTools.GetObjectResult <Grounp>(sql, null); } else { string sql = "select * from grounp where name like '%" + keyName + "%' ORDER BY id DESC"; result = MySqlExecuteTools.GetObjectResult <Grounp>(sql, null); } result.ForEach((item) => { if (item.fenceLat > 0) { item.isDefence = true; } }); //管理员 if (userType.Equals("1")) { Grounp grounp = result.Where((item) => item.userId == int.Parse(userId)).FirstOrDefault <Grounp>(); result.Remove(grounp); result.Insert(0, grounp); } else { //当前的grounp显示top Grounp p = GetGrounpByPlayer(int.Parse(userId)); if (p != null) { Grounp grounp = result.Where((item) => item.id == p.id).FirstOrDefault <Grounp>(); result.Remove(grounp); result.Insert(0, grounp); } } DataResult dataResult = new DataResult(); dataResult.result = 0; dataResult.data = result; session.Send(GetSendData(dataResult, body)); }
public static void ConnectionAccepted(PubgSession Session) { Session.Client.SendMessage("[0,null,\"ClientApi\",\"ConnectionAccepted\",\"account.d97a9d0dc25948f18348816373392734\",{\"profile\":{\"Nickname\":\"xxVertigo\",\"ProfileStatus\":null,\"InviteAllow\":\"all\",\"Skin\":{\"Gender\":\"female\",\"Hair\":\"skindesc.female.hair.02.02\",\"Face\":\"skindesc.female.face.01.01\",\"Presets\":\"female:F_Hair_B_02:F_Face_01:F_NudeBody_01\"}},\"inventory\":null,\"record\":null,\"account\":{\"AccountId\":\"account.d97a9d0dc25948f18348816373392734\",\"Origin\":\"steam.76561198073428385\",\"Region\":\"na\",\"PartnerId\":null,\"MatchAndPerspective\":\"solo\"},\"inviteAllow\":\"all\",\"playinggame\":null,\"avatarUrl\":\"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/58/58996926e5392cfeafbc867571cb7fc75fb5ecba.jpg\",\"lobbyAppConfig\":{\"REPORT_URL\":\"https://prod-live-report-server.pubgbluehole.com/report\"},\"pingServers\":[{\"Key\":\"na\",\"Value\":\"35.153.218.241:31112\"},{\"Key\":\"as\",\"Value\":\"13.125.109.210:31112\"},{\"Key\":\"sea\",\"Value\":\"13.229.164.235:31112\"},{\"Key\":\"oc\",\"Value\":\"13.210.157.45:31112\"},{\"Key\":\"eu\",\"Value\":\"18.196.152.192:31112\"},{\"Key\":\"sa\",\"Value\":\"18.231.45.91:31112\"},{\"Key\":\"krjp\",\"Value\":\"13.125.109.210:31112\"},{\"Key\":\"kakao\",\"Value\":\"13.125.109.210:31112\"}],\"broOnlineServices\":{\"AuthenticationOff\":false,\"InventoryOff\":false,\"EquipOff\":false,\"StoreOff\":false,\"SkinOff\":false,\"PromotionCodeOff\":false,\"RecordOff\":false,\"MatchMakerOff\":false,\"PartyOff\":false,\"CustomGameOff\":false,\"OuterOff\":false,\"RejoinOff\":false,\"LoginCheckOff\":false,\"SteamCircuitBreakerOff\":false,\"LobbyVoiceChatOff\":false,\"TemporaryBanOff\":false,\"ClientValidationOff\":false,\"VpnCheckOff\":false},\"autoRequestMatch\":{\"On\":false,\"Region\":null,\"MatchType\":null}}]"); /* var Message = new Message(0, null, "ClientApi", "ConnectionAccepted"); * * Message.Parameters.Add(Session.Account.AccountId); * Message.Parameters.Add(Session.Player.Save()); * * Session.Client.SendMessage(Message); */ Invalidate(Session, "party"); Invalidate(Session, "match"); Invalidate(Session, "game"); Invalidate(Session, "event"); }
/// <summary> /// Delete /// </summary> /// <param name="session"></param> /// <param name="body"></param> /// <param name="id">roomid</param> /// <param name="userId">用户id</param> public void DeleteRoom(PubgSession session, string body, string roomId, string userId) { DataResult dataResult = new DataResult(); //判断当前用户是具有删除的权限 string sql = "select * from room where id = @room_id and userId = @userId"; int roomCount = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@room_id", roomId), new MySqlParameter("@userId", userId) }); if (roomCount == 0) { dataResult.result = 1; dataResult.resean = "操作错误,无删除权限"; session.Send(GetSendData(dataResult, body)); return; } sql = "select * from room_user where room_id = @room_id and user_id <> @userId"; int countResult = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@room_id", roomId), new MySqlParameter("@userId", userId) }); if (countResult > 0) { dataResult.result = 1; dataResult.resean = "战队下有玩家用户,无法进行删除"; session.Send(GetSendData(dataResult, body)); return; } //删除队长创建的room sql = "delete from room where id = @id"; MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@id", roomId) }); //删除room_user sql = "delete from room_user where user_id = @user_id"; MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@user_id", userId) }); dataResult.result = 0; //查询能否删除 session.Send(GetSendData(dataResult, body)); }
public void RegisterUser(PubgSession session, string body, string telephone, string password, string name, string icon, string checkCode, string userType) { // Logger.InfoFormat("新的客户端断开:{0}", session.RemoteEndPoint); string sql = "select * from user where telephone = @telephone"; int result = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@telephone", telephone) }); DataResult dataResult = new DataResult(); if (result > 0) { dataResult.result = 1; dataResult.resean = "手机号码已注册,请重试"; } else { int type = Convert.ToInt32(userType); dataResult.result = 0; sql = "insert into user(password,name ,telephone,image,type) " + "values('" + password + "','" + name + "','" + telephone + "','" + icon + "','" + type + "')"; long newuserId = MySqlExecuteTools.GetAddID(sql); //玩家,增加生命信息 if (type == 0) { sql = "insert into life(userId) " + "values('" + newuserId + "')"; MySqlExecuteTools.AddOrUpdate(sql); } //管理员,增加一条grounp数据 if (type == 1) { sql = "insert into grounp(name,userId) " + "values('" + name + "','" + newuserId + "')"; MySqlExecuteTools.AddOrUpdate(sql); } } session.Send(GetSendData(dataResult, body)); }
/// <summary> /// Delete /// </summary> /// <param name="session"></param> /// <param name="body"></param> /// <param name="id">roomid</param> /// <param name="userId">用户id</param> public void ExitRoom(PubgSession session, string body, string roomId, string userId, string userName) { string sql = "select * from room_user where user_id = @user_id"; List <Room_User> grounp_UserList = MySqlExecuteTools.GetObjectResult <Room_User>(sql, new MySqlParameter[] { new MySqlParameter("@user_id", userId) }); DataResult dataResult = new DataResult(); if (grounp_UserList.Count == 0) { dataResult.result = 1; dataResult.resean = "非法操作"; session.Send(GetSendData(dataResult, body)); return; } Grounp p = GetGrounpByPlayer(int.Parse(userId)); if (p != null && p.runState == 0) { dataResult.result = 1; dataResult.resean = "游戏运行中,无法退出战队。"; session.Send(GetSendData(dataResult, body)); return; } // 删除之前提示 sql = "select name from room where id=" + roomId; string rommName = MySqlExecuteTools.GetSingleFieldResult(sql, null)[0].ToString(); publishTipsMessage.JoinAndExitLeader(userName, int.Parse(userId), rommName, false); sql = "delete from room_user where id = @id"; MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@id", grounp_UserList[0].id) }); dataResult.result = 0; session.Send(GetSendData(dataResult, body)); //刷新缓存数据 GetRoomUserData(); }
/// <summary> /// Adds the specified entity. /// </summary> /// <param name="Entity">The entity.</param> public bool TryAdd(PubgSession Entity) { if (this.Entities.ContainsKey(Entity.ID)) { Log.Error(typeof(Sessions), "ContainsKey(Entity.ID) != false at Add(Entity)."); } else { if (this.Entities.TryAdd(Entity.ID, Entity)) { return(true); } else { Log.Error(typeof(Sessions), "TryAdd(Entity.ID, Entity) != true at Add(Entity)."); } } return(false); }
/// <summary> /// Removes the specified entity. /// </summary> /// <param name="Entity">The entity.</param> public bool TryRemove(PubgSession Entity) { if (this.Entities.TryRemove(Entity.ID, out PubgSession TmpEntity)) { if (TmpEntity.ID == Entity.ID) { return(true); } else { Log.Error(typeof(Sessions), "TmpEntity.ID != Entity.ID at Remove(Entity)."); } } else { Log.Error(typeof(Sessions), "TryRemove(Entity.ID, out TmpEntity) != true at Remove(Entity)."); } return(false); }
/// <summary> /// Called when the WebSocket connection used in a session has been established. /// </summary> protected override async void OnOpen() { string Provider = this.Context.QueryString.Get("provider"); string Ticket = this.Context.QueryString.Get("ticket"); string Username = this.Context.QueryString.Get("id"); string Password = this.Context.QueryString.Get("password"); string PlayerId = this.Context.QueryString.Get("playerNetId"); string Country = this.Context.QueryString.Get("cc"); string Version = this.Context.QueryString.Get("clientGameVersion"); var PubgSession = new PubgSession(this); if (this.Server.Sessions.TryAdd(PubgSession)) { var Authenticated = await this.Authenticate(PubgSession, Provider, Ticket, Username, Password, PlayerId, Country, Version); if (Authenticated) { ClientApi.ConnectionAccepted(PubgSession); } else { Lobby.Log.Warning(this.GetType(), "Authenticated != true at OnOpen()."); PubgSession.Player = new Player { Username = Username, Password = Password }; await this.Server.Database.Create(PubgSession.Player); ClientApi.ConnectionAccepted(PubgSession); } } else { Lobby.Log.Warning(this.GetType(), "At OnOpen(), TryAdd(PubgSession) == false, aborting."); } }
public void CheckLogin(PubgSession session, string body, string username, string password) { Logger.InfoFormat("用户登陆验证:{0}", username); string sql = "select * from user where telephone = @username and password = @password"; List <UserName> result = MySqlExecuteTools.GetObjectResult <UserName> (sql, new MySqlParameter[] { new MySqlParameter("@username", username), new MySqlParameter("@password", password) }); DataResult dataResult = new DataResult(); if (result.Count == 0) { dataResult.result = 1; dataResult.resean = "账号或密码有误,请重试!"; } else { bool isLogin = CheckIsLogin(result[0].id.ToString()); if (isLogin) { dataResult.result = 1; dataResult.resean = "该账号已在线,不能重复登录,请重试!"; } else { dataResult.result = 0; UserName userName = result[0]; sql = "select * from room where userId = @userId"; int count = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@userId", userName.id) }); if (count > 0) { userName.isLeader = true; } dataResult.data = userName; } } session.Send(GetSendData(dataResult, body)); }
public static void GetInventory(Message Message, PubgSession Session) { var Callback = new Message(-Message.Identifier, null, true); if (Session.IsAuthenticated) { var Inventory = JsonConvert.SerializeObject(Session.Player.Inventory); if (Inventory != null) { Callback.SetResult(Result: JObject.Parse(Inventory)); } else { Callback.SetResult(Error: "This f****t's inventory is null."); } } else { Callback.SetResult(Error: "This f****t is not authenticated."); } Session.Client.SendMessage(Callback); }
public void CreateEditRoom(PubgSession session, string body, string grounpId, string gamePassword, string roomId, string roomName, string checkCode, string userId) { Logger.InfoFormat("创建编辑房间:{0},{1},{2},{3}", grounpId, roomId, roomName, checkCode); DataResult dataResult = new DataResult(); string sql = "select * from grounp where id = @id and checkCode = @checkCode"; int result = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@id", grounpId), new MySqlParameter("@@checkCode", gamePassword) }); if (result == 0) { dataResult.result = 1; dataResult.resean = "游戏密码错误,操作失败"; session.Send(GetSendData(dataResult, body)); return; } //ADD if (roomId.Equals("-1")) { //每个用户只能创建一个房间 sql = "select * from room where userId = @userId"; int roomCount = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@userId", userId) }); if (roomCount >= 1) { dataResult.result = 1; dataResult.resean = "创建失败,每个队长只能创建一个战队"; session.Send(GetSendData(dataResult, body)); return; } //不能加入其他队还进行队的创建 sql = "select * from room_user where user_id = @userId"; roomCount = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@userId", userId) }); if (roomCount > 0) { dataResult.result = 1; dataResult.resean = "创建失败,您已经加入战队,无法再次创建"; session.Send(GetSendData(dataResult, body)); return; } //创建房间 sql = "insert into room(grounpId,name,checkCode,userId) " + "values('" + grounpId + "','" + roomName + "','" + checkCode + "','" + userId + "')"; long newRoomId = MySqlExecuteTools.GetAddID(sql); //用户加入到该房间 sql = "insert into room_user(room_id,user_id) " + "values('" + newRoomId + "','" + userId + "')"; MySqlExecuteTools.AddOrUpdate(sql); } //更新 else { sql = "update room set name = '" + roomName + "', checkCode = '" + checkCode + "' where id = @roomid;"; MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@roomid", roomId) }); } dataResult.result = 0; session.Send(GetSendData(dataResult, body)); }
public void JoinRoom(PubgSession session, string body, string checkCode, string grounpId, string roomId, string userId, string userName) { Logger.InfoFormat("加入队:{0},{1}", roomId, userId); string sql = "select * from room_user where user_id = @user_id"; List <Room_User> grounp_UserList = MySqlExecuteTools.GetObjectResult <Room_User>(sql, new MySqlParameter[] { new MySqlParameter("@user_id", userId) }); DataResult dataResult = new DataResult(); if (grounp_UserList.Count > 0) { dataResult.result = 1; dataResult.resean = "您已经加入房间,不能重复。"; session.Send(GetSendData(dataResult, body)); return; } //校验checkcode是否正确 sql = "select * from room where id = @roomId and checkCode = @checkCode"; int countResult = MySqlExecuteTools.GetCountResult(sql, new MySqlParameter[] { new MySqlParameter("@roomId", roomId), new MySqlParameter("@checkCode", checkCode) }); if (countResult == 0) { dataResult.result = 1; dataResult.resean = "进入房间的密码不正确,请重试。"; session.Send(GetSendData(dataResult, body)); return; } Grounp p = SearchGrounpDao.GetGrounpById(grounpId); if (p != null && p.runState == 0) { dataResult.result = 1; dataResult.resean = "游戏运行中,无法加入战队。"; session.Send(GetSendData(dataResult, body)); return; } sql = "select * from room where id = @roomId"; List <Room> roomList = MySqlExecuteTools.GetObjectResult <Room>(sql, new MySqlParameter[] { new MySqlParameter("@roomId", roomId) }); if (roomList.Count == 1 && roomList[0].runState == 0) { dataResult.result = 1; dataResult.resean = "该战队已经准备就绪,无法加入,请重试。"; session.Send(GetSendData(dataResult, body)); return; } //grounp_UserList = SearchSingleGrounpCommon(roomId); //if (grounp_UserList.Count> maxNum) //{ // dataResult.result = 1; // dataResult.resean = "房间人数加入已满,请重试。"; //} //else //{ sql = "insert into room_user(room_id,user_id) " + "values('" + roomId + "','" + userId + "')"; MySqlExecuteTools.AddOrUpdate(sql); dataResult.result = 0; //推送数据 sql = "select name from room where id=" + roomId; string rommName = MySqlExecuteTools.GetSingleFieldResult(sql, null)[0].ToString(); publishTipsMessage.JoinAndExitLeader(userName, int.Parse(userId), rommName, true); // } session.Send(GetSendData(dataResult, body)); GetRoomUserData(); }
public static void Ping(Message Message, PubgSession Session) { // Ping. }
public static void GetPartyData(Message Message, PubgSession Session) { // GetPartyData. }
public static void GetOpenGameInfo(Message Message, PubgSession Session) { // GetOpenGameInfo. Session.Client.SendMessage("[-10012,null,true,{\"Error\":null,\"Result\":{\"OfficialDivisionIds\":[{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"solo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"duo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"as\",\"PartyType\":\"squad-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"solo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"duo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"eu\",\"PartyType\":\"squad-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"solo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"duo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"oc\",\"PartyType\":\"squad-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"solo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"duo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"na\",\"PartyType\":\"squad-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sa\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sa\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sa\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sa\",\"PartyType\":\"solo-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sa\",\"PartyType\":\"squad-fpp\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sea\",\"PartyType\":\"solo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sea\",\"PartyType\":\"duo\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sea\",\"PartyType\":\"squad\"},{\"IdType\":\"division\",\"GameType\":\"bro\",\"LeagueType\":\"official\",\"SeasonType\":\"2018-04\",\"RegionType\":\"sea\",\"PartyType\":\"squad-fpp\"}],\"EventModes\":[]}}]"); }