private void OnRegister(JHSNetworkMessage netMsg) { string msg = ""; Register packet = netMsg.ReadMessage <Register>(); if (packet != null) { switch (packet.Code) { case ErrorCodes.SUCCESS: msg = "Welcome, your account has been created you may now login."; MainComponent.Core.SendNotification(ProgramConst.SHOW_PROPMPT, msg); MainComponent.Core.SendNotification(ProgramConst.SHOW_BOX, msg); break; case ErrorCodes.USER_EXIST: msg = "Username already exists please choose another."; MainComponent.Core.SendNotification(ProgramConst.SHOW_PROPMPT, msg); MainComponent.Core.SendNotification(ProgramConst.SHOW_BOX, msg); break; case ErrorCodes.WRONG_PASSWORD: case ErrorCodes.GENERAL_FAILURE: break; } } }
public bool Execute(JHSNetworkMessage msg) { ChatMsg packet = msg.ReadMessage <ChatMsg>(); if (packet != null) { if (userManager == null) { userManager = UserManager.Instance; } if (chatmanager == null) { chatmanager = ChatManager.Instance; } uint connectionId = msg.conn.connectionId; User user = userManager.GetUserByConnectionId(connectionId); if (user != null) { chatmanager.SendToAll(user.UserName, packet.msg, JHSTime.TimeStamp); } } return(true); }
private void OnLogin(JHSNetworkMessage netMsg) { LoginResponse packet = netMsg.ReadMessage <LoginResponse>(); if (packet != null) { switch (packet.Code) { case ErrorCodes.SUCCESS: MainCache.Credit = packet.Credits; SitesManager.Init(packet.sites); MainCache.MemberType = packet.MemberType; MainCache.SurfedSites = packet.SurfedSites; MainCache.LoggedIn = true; MainComponent.Core.SendNotification(ProgramConst.SHOW_MAIN); MainComponent.state = ProgramState.LOGGED_IN; break; case ErrorCodes.WRONG_PASSWORD: string msg = "Wrong username or password!"; MainComponent.Core.SendNotification(ProgramConst.SHOW_PROPMPT, msg); MainComponent.Core.SendNotification(ProgramConst.SHOW_BOX, msg); break; } } }
public bool Execute(JHSNetworkMessage msg) { UserOpenChat packet = msg.ReadMessage <UserOpenChat>(); if (packet != null) { if (userManager == null) { userManager = UserManager.Instance; } if (chatmanager == null) { chatmanager = ChatManager.Instance; } uint connectionId = msg.conn.connectionId; User user = userManager.GetUserByConnectionId(connectionId); if (user != null) { if (packet.isopen) { chatmanager.RegisterOpenUser(connectionId); } else { chatmanager.RemoveFromView(connectionId); } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (rankingManager == null) { rankingManager = RankingManager.Instance; } Empty packet = netMsg.ReadMessage <Empty>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ account = DbManager.GetOnlineByConnectionId(connectionId); if (account != null) { if (account.RankRequestTime > JHSTime.Time) { netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { PayLoadType = RankingPacketType.ERROR }); return(true); } account.RankRequestTime = JHSTime.Time + Settings.CAN_REQUEST_RANK_UPDATE_TIME; RankinngOBJ rankings = rankingManager._GetPlayer(account); if (rankings != null) { if (rankings.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS) { netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { GameCount = rankings.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS ? (byte)(Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS - rankings.GameCount) : (byte)0, PayLoadType = RankingPacketType.GAME_COUNT, }); return(true); } LeagueData[] data = rankingManager._GetLegue(rankings.League); netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { CurrentLeague = rankings.League, GameCount = (byte)rankings.GameCount, LeaguePosition = (byte)(rankings.RankNo > 100 ? 255: rankings.RankNo), PayLoadType = RankingPacketType.UPDATE_DATA, rankingData = data, LeaguePoints = (uint)rankings.LeaguePoints }); } } } return(true); }
private void CONNECTED_TO_SERVER(JHSNetworkMessage netMsg) { Connected = true; MainComponent.Core.SendNotification(ProgramConst.SHOW_PROPMPT, "Connected to server."); if (MainComponent.state == ProgramState.LOGGED_IN) { MainComponent.Core.SendNotification(DO_LOGIN, new string[] { MainCache.UserName, MainCache.PassWord }); } }
private void OnNetworkReceive(JHSNetworkMessage netMsg) { if (m_MessageHandlersDict.TryGetValue(netMsg.msgType, out IJHSInterface handler)) { lock (handler) { handler.Execute(netMsg); } } }
private static void TESTMSGREC(JHSNetworkMessage netMsg) { SearchMatch msg = netMsg.ReadMessage <SearchMatch>(); if (msg != null) { Time = JHSTime.Time + 5; Console.WriteLine(msg.op.ToString()); } }
private void OnChatRecieve(JHSNetworkMessage netMsg) { ChatMsg packet = netMsg.ReadMessage <ChatMsg>(); if (packet != null) { MainCache.chatList.Add(packet); MainComponent.Core.SendNotification(REFRESH_CHAT_WINDOW); } }
public bool Execute(JHSNetworkMessage netmsg) { Login packet = netmsg.ReadMessage <Login>(); if (packet != null) { if (userManager == null) { userManager = UserManager.Instance; } if (PasswordUtils.ValidLogin(packet.UserName) && PasswordUtils.ValidPassword(packet.Password)) { User user = userManager.GetUserByName(packet.UserName); if (user != null) { if (PasswordUtils.ComparePasswords(user.Password, packet.Password)) { uint connectionId = netmsg.conn.connectionId; lock (user) { user._data.loginTime = DateTime.UtcNow; user._data.lastKnownIp = user._data.ip; user._data.ip = netmsg.conn.IP; user.SetSites(userManager.GetUserSites(user.UserId)); } DbService.SubmitUpdate2Queue(user.UserId, user._data); userManager.AddOnline(connectionId, user); LoginResponse response = new LoginResponse { Code = SUCCESS, MemberType = user.MemberType, SurfedSites = (uint)user.ViewsToday, Credits = user.Credits }; response.sites = user.Sites; netmsg.conn.Send(NetworkConstants.LOGIN, response); return(true); } } } else { netmsg.conn.Send(NetworkConstants.LOGIN, new LoginResponse() { Code = WRONG_PASSWORD }); return(true); } netmsg.conn.Send(NetworkConstants.LOGIN, new LoginResponse() { Code = WRONG_PASSWORD }); } return(true); }
private void OnRecNewSurfSite(JHSNetworkMessage netMsg) { UrlDetails packet = netMsg.ReadMessage <UrlDetails>(); if (packet != null) { MainCache.Credit += MainCache.AddCredit; MainCache.SurfedSites += 1; MainComponent.Core.SendNotification(SHOW_MAIN); MainComponent.Core.SendNotification(GOT_NEW_URL, packet); } }
private static void CONNECTED_TO_SERVER(JHSNetworkMessage netMsg) { if (netMsg.conn != null) { Console.Title = "Connection:" + netMsg.conn.connectionId; Console.WriteLine("CONNECTED_TO_SERVER CONNECTION ID:" + netMsg.conn.connectionId); } else { Console.WriteLine("CONNECTED_TO_SERVER"); } }
private void OnDisconnect(JHSNetworkMessage netMsg) { User user = UserManager.Instance.GetUserByConnectionId(netMsg.conn.connectionId); if (user != null) { lock (user) { user.OnLogout(); UserManager.Instance.RemoveOnline(netMsg.conn.connectionId); } } }
private void OnDataUpdatedSuccesfuly(JHSNetworkMessage netMsg) { SubmitDataForUpdate data = netMsg.ReadMessage <SubmitDataForUpdate>(); if (data != null && data.Code == ErrorCodes.JUST_DATA_UPDATE) { SitesManager.Init(data.Changed); } else { SitesManager.UpdateSuccess(); } }
public void SendToClients(int[] v, short msgId, JHSNetworkMessage sr, bool reliable = true) { /* * if (NetworkGameServer == null) * return; * for (int index = 0; index < v.Length; ++index) * { * TcpPlayer player = NetworkGameServer.GetPlayer(v[index]); * if (player != null) * player.Send(msgId, (DRMessage)sr, reliable); * } */ }
public void OnDisconnect(JHSNetworkMessage netMsg) { AccountOBJ user = DbManager.GetOnlineByConnectionId(netMsg.conn.connectionId); if (user != null) { lock (user) { user.OnLogout(); DbManager.RemoveOnline(netMsg.conn.connectionId); user.InQueue = false; } } queueManager.RemoveServer(netMsg.conn.connectionId); }
public bool Execute(JHSNetworkMessage netMsg) { if (queueManager == null) { queueManager = GameServerManager.Instance; } GameServerLogin packet = netMsg.ReadMessage <GameServerLogin>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; var server = queueManager.GetServerByConnectionId(connectionId); if (server == null) { if (Settings.BINDPASSWORD == packet.PassWord) { if (queueManager.AddServer(connectionId, packet)) { netMsg.conn.Send(GameServerOP.UPDATE_STATE, packet); } } } else { if (server != null) { lock (server) { server.status = packet.gameMatchState; LOG.Info("OnChangeSession ServerId[" + connectionId + "] Status[" + packet.gameMatchState.ToString() + "]"); } } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } Empty packet = netMsg.ReadMessage <Empty>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ account = DbManager.GetOnlineByConnectionId(connectionId); if (account != null) { netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives() { actives = account.SerializeActives() }); } } return(true); }
public bool Execute(JHSNetworkMessage msg) { Ask4NewURL packet = msg.ReadMessage <Ask4NewURL>(); if (packet != null) { if (userManager == null) { userManager = UserManager.Instance; } uint connectionId = msg.conn.connectionId; User user = userManager.GetUserByConnectionId(connectionId); if (user != null) { lock (user) { if (user.LastViedSite != null) { if (user.LastRequestTime > JHSTime.Time) { msg.conn.Send(NetworkConstants.GET_NEW_URL, new UrlDetails() { code = ErrorCodes.SUCCESS, Time = user.LastViedSite.Time, Url = user.LastViedSite.url }); user.LastRequestTime = JHSTime.Time + user.LastViedSite.Time; return(true); } uint reward = 0; switch (user.MemberType) { case UserType.FREE: reward = (uint)(user.LastViedSite.Time * 0.5f); break; default: reward = user.LastViedSite.Time; break; } User other = userManager.GetUserByUserID(user.LastViedSite.UID); if (other != null) { uint take = other.Credits - user.LastViedSite.Time; if (take > 0) { other.Credits = take; } else { other.Credits = 0; } DbService.UpdateEntityIntime(other.UserId, other._data); } user.ViewdSites.Add(user.LastViedSite.id); user.Credits = reward; DbService.UpdateEntityIntime(user.UserId, user._data); } ISession session = DbService.GetDBSession; if (session != null) { var sql = "SELECT userurls.id,userurls.UID,userurls.WebsiteName,userurls.region,userurls.url,userurls.Referral,userurls.Time,userurls.ViewCount,userurls.IsActive FROM userurls,useraccounts WHERE userurls.IsActive = 1 AND useraccounts.UserId = userurls.UID AND useraccounts.credits > 120 AND userurls.id NOT IN(" + user.GetViewdSitesString() + ") AND useraccounts.UserId != " + user.UserId + " LIMIT 1"; var query = session.CreateSQLQuery(sql).AddEntity(typeof(UserUrls)); UserUrls objectList = query.UniqueResult <UserUrls>(); if (objectList != null) { msg.conn.Send(NetworkConstants.GET_NEW_URL, new UrlDetails() { code = ErrorCodes.SUCCESS, Time = objectList.Time, Url = objectList.url }); user.LastViedSite = objectList; user.LastRequestTime = JHSTime.Time + user.LastViedSite.Time; } else { msg.conn.Send(NetworkConstants.GET_NEW_URL, new UrlDetails() { code = ErrorCodes.NO_MORE_SITES }); } } } } } return(true); }
private static void DISCONNECTED_FROM_SERVER(JHSNetworkMessage netMsg) { Console.WriteLine("DISCONNECTED_FROM_SERVER"); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (queueManager == null) { queueManager = GameServerManager.Instance; } if (dbService == null) { dbService = DbService.Instance; } ReqeuestUser packet = netMsg.ReadMessage <ReqeuestUser>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; var server = queueManager.GetServerByConnectionId(connectionId); if (server != null || Settings.DEBUG_GET_PLAYER) { AccountOBJ user = DbManager.GetOnlineByUserId(packet.userId); if (Settings.DEBUG_GET_PLAYER && user == null) { user = dbService.GetAccountFromDB(packet.userId); user.SelectedCharacer = user.FirstRole().PlayerId; } if (user != null) { if (user.SelectedCharacer != 0) { DBPlayer role = user.GetRole(user.SelectedCharacer); if (role != null) { if (packet.Type == InfoType.NONE) { netMsg.conn.Send(GameServerOP.GETROLE, new LoginDataBasePlayer() { STATUS = SUCCESS, player = role, REQ = packet.Req }); } else { netMsg.conn.Send(GameServerOP.GET_ROLE2, new UpdateRole() { STATUS = SUCCESS, player = role, TYPE = packet.Type }); } LOG.Info(string.Format("GETRole :: REQ[{3}] id[{0}] userid[{1}] serverid[{2}]", role.Base.PlayerId, role.Base.UserId, connectionId, packet.Req)); return(true); } } } netMsg.conn.Send(GameServerOP.GETROLE, new LoginDataBasePlayer() { STATUS = PLAYER_NOT_FOUND }); } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } CollectActive packet = netMsg.ReadMessage <CollectActive>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { lock (user) { ActivesConfig model = ConfigManager.GetActive((int)packet.AciveId); if (model == null) { netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse() { STATUS = ITEM_CONFIG_WRONG }); return(true); } ActivesOBJ active = user.GetActive((int)packet.AciveId); if (active == null) { netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse() { STATUS = ACTIVE_NOT_FOUND }); return(true); } if (active.Collected) { netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse() { STATUS = ACTIVE_ALREADY_COLLECTED }); return(true); } if (model.Conditions != active.Value) { netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse() { STATUS = ACTIVE_NOT_COMPLEATED }); return(true); } active.Collected = true; DbService.SubmitUpdate2Queue(active); if (model.GoldReward > 0) { user.Gold += model.GoldReward; } if (model.SilverReward > 0) { user.Silver += model.SilverReward; } user.ResetNotification(); DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse() { STATUS = SUCCESS, AciveId = packet.AciveId, Gold = (uint)user.Gold, Silver = (uint)user.Silver }); } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } DeleteCharacter packet = netMsg.ReadMessage <DeleteCharacter>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { lock (user) { if (user.Skins.Count <= 1) { netMsg.conn.Send(NetworkConstants.DELETE_CHARACTER, new DeleteCharacterResponse() { STATUS = NOT_DELETE_LAST_CHARACTER }); return(true); } CharacterOBJ character = user.GetPlayer(packet.PlayerId); if (character != null) { ConfiModel model = ConfigManager.GetModel(character.SkinId); if (model == null) { netMsg.conn.Send(NetworkConstants.DELETE_CHARACTER, new DeleteCharacterResponse() { STATUS = ITEM_CONFIG_WRONG }); return(true); } uint playerId = character.PlayerId; if (DbService.RemoveEntity(character.GetEntity()) && user.Skins.Remove(playerId)) { user.Silver += model.SilverPrice; user.ResetNotification(); DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.DELETE_CHARACTER, new DeleteCharacterResponse() { STATUS = SUCCESS, PlayerId = playerId, Gold = (uint)user.Gold, Silver = (uint)user.Silver }); } else { netMsg.conn.Send(NetworkConstants.DELETE_CHARACTER, new DeleteCharacterResponse() { STATUS = PLAYER_NOT_FOUND }); } } else { netMsg.conn.Send(NetworkConstants.DELETE_CHARACTER, new DeleteCharacterResponse() { STATUS = PLAYER_NOT_FOUND }); } } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (matchQueue == null) { matchQueue = PlayerQueueManager.Instance; } SearchMatch packet = netMsg.ReadMessage <SearchMatch>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { switch (packet.op) { case SearchMatchOperations.Search: if (user.InQueue) { netMsg.conn.Send(NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = SearchMatchOperations.NO_ERROR_SEARCHING }); return(true); } CharacterOBJ player = user.GetPlayer(packet.value); if (player != null) { lock (user) { user.SelectedCharacer = player.PlayerId; user.InQueue = true; user.ResetNotification(); matchQueue.AddPlayer(new MatchPlayer() { League = user.League, userId = user.Id, ConnectionId = connectionId, PlayerId = player.PlayerId }); netMsg.conn.Send(NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = SearchMatchOperations.SEARCHING_INIT, value = (uint)matchQueue.AvregeWaitTime() }); } } else { netMsg.conn.Send(NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = SearchMatchOperations.ERR_CHARATER_NOT_THERE }); } break; case SearchMatchOperations.Cancel: lock (user) { user.SelectedCharacer = 0; user.InQueue = false; netMsg.conn.Send(NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = SearchMatchOperations.Cancel }); } break; case SearchMatchOperations.CHECK_START: matchQueue.CheckStart(); break; } } else { netMsg.conn.Send(NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = SearchMatchOperations.ERR_ACCOUNT_NOT_FOUND }); } } return(true); }
public bool Execute(JHSNetworkMessage msg) { SubmitDataForUpdate packet = msg.ReadMessage <SubmitDataForUpdate>(); if (packet != null) { if (userManager == null) { userManager = UserManager.Instance; } uint connectionId = msg.conn.connectionId; User user = userManager.GetUserByConnectionId(connectionId); if (user != null) { lock (user) { bool delted = false; foreach (SiteClass site in packet.Added) { site.UserId = user.UserId; SiteClass n = new SiteClass(DbService.CreateEntity(site._data)); user.AddOrUpdateSite(n); DbService.SubmitUpdate2Queue(n.UID, n._data); } foreach (SiteClass site in packet.Changed) { SiteClass v = user.GetSite(site.SiteIndex); if (v != null) { v.WebsiteName = site.WebsiteName; v.Url = site.Url; v.Region = site.Region; v.Referral = site.Referral; v.IsActive = site.IsActive; v.Time = site.Time; user.AddOrUpdateSite(v); DbService.SubmitUpdate2Queue(v.UID, v._data); } } foreach (int site in packet.Deleted) { SiteClass v = user.GetSite(site); if (v != null) { delted = true; user.RemoveSite(site); DbService.RemoveEntityFromDatabase <UserUrls>(v.UID); } } if (delted) { user.ReorderSites(); } msg.conn.Send(NetworkConstants.UPDATE_SITE_DATA, new SubmitDataForUpdate() { Code = delted ? ErrorCodes.JUST_DATA_UPDATE : ErrorCodes.GENERAL_FAILURE, Changed = user.Sites }); } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (queueManager == null) { queueManager = GameServerManager.Instance; } if (dbService == null) { dbService = DbService.Instance; } UpdateMatchResult packet = netMsg.ReadMessage <UpdateMatchResult>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; var server = queueManager.GetServerByConnectionId(connectionId); if (server != null) { AccountOBJ user = DbManager.GetOnlineByUserId(packet.UserId); if (user == null) { user = dbService.GetAccountFromDB(packet.UserId); } if (user != null) { lock (user) { foreach (DBPlayerActive active in packet.Actives) { ActivesOBJ obj = user.GetActive((int)active.ActiveId); obj.Value = (int)active.Value; DbService.UpdateEntityIntime(obj); } user.Data.Exp += (int)packet.EXP; RankinngOBJ RankData = RankingManager.GetPlayer(user); if (RankData != null) { RankData.GameCount += 1; RankData.Kills += (int)packet.KillCount; if (!packet.HasWon) { RankData.Deaths += 1; } } user.OnGameResultRecieved(); DbService.UpdateEntityIntime(user); } LOG.Info(string.Format("SaveResult :: Server[{0}] userid[{1}]", connectionId, packet.UserId)); } else { LOG.Info(string.Format("SaveResult Error unknown user :: Server[{0}] userid[{1}]", connectionId, packet.UserId)); } netMsg.conn.Send(GameServerOP.PUTROLE, new Empty()); } } return(true); }
private static void DISCONNECTED_PERMANENT(JHSNetworkMessage netMsg) { Console.WriteLine("DISCONNECTED_PERMANENT"); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } GWLoginPacket packet = netMsg.ReadMessage <GWLoginPacket>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetAccountFromDbByUserName(packet.LoginName); if (user != null) { lock (user) { string userName = user.Username; if (userName.VerifyPassword(user.Password, packet.Password)) { //RESPONSE LOGIC lock (user) { user.connectionID = connectionId; user.LoginTime = DateTime.Now; user.LastKnownIp = user.Ip; user.Ip = netMsg.conn.IP; user.OnLogin(); DbService.SubmitUpdate2Queue(user); } // RankinData ranking = rankingManager.GetUser(user); GWLoginResponsePacket dat = new GWLoginResponsePacket { actives = user.GetActiveCompleate(), characters = user.SerializeChars(), RESPONSE = SUCCESS, League = user.League, LeaguePosition = user.LeaguePosition, LEGUE_STATUS = user.LegueStatus, PlayerNick = user.PlayerName, Gold = (uint)user.Gold, Silver = (uint)user.Silver, Priviledge = (byte)user.Priviledge, LoginTocken = user.Id, LEVEL = (uint)user.Data.Level, EXP = (uint)user.Data.Exp, IsPushLevelUp = user.LevelUpNotify, SEASON = (byte)Settings.RANKING_SEASON, GameCount = user.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS ? (byte)(Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS - user.GameCount) : (byte)0 }; DbManager.RegisterOnline(connectionId, user); JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, dat); } else { JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, new GWLoginResponsePacket() { RESPONSE = WRONG_PASSWORD_OR_LOGIN }); } } } else { if (Settings.AutoCreate) { user = CreateAccount(packet); lock (user) { user.connectionID = connectionId; user.LoginTime = DateTime.Now; user.LastKnownIp = user.Ip; user.Ip = netMsg.conn.IP; user.OnLogin(); DbService.UpdateEntityIntime(user); } user = DbManager.GetAccountFromDbByUserName(packet.LoginName); if (user != null) { GWLoginResponsePacket dat = new GWLoginResponsePacket { actives = user.GetActiveCompleate(), characters = user.SerializeChars(), RESPONSE = SUCCESS, League = user.League, LeaguePosition = user.LeaguePosition, LEGUE_STATUS = user.LegueStatus, PlayerNick = user.PlayerName, Gold = (uint)user.Gold, Silver = (uint)user.Silver, Priviledge = (byte)user.Priviledge, LoginTocken = user.Id, LEVEL = (uint)user.Data.Level, EXP = (uint)user.Data.Exp, IsPushLevelUp = user.LevelUpNotify, SEASON = (byte)Settings.RANKING_SEASON, GameCount = user.GameCount < 5 ? (byte)(5 - user.GameCount) : (byte)0 }; DbManager.RegisterOnline(connectionId, user); JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, dat); } } else { JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, new GWLoginResponsePacket() { RESPONSE = USER_NOT_FOUND }); } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } ExchangeCur packet = netMsg.ReadMessage <ExchangeCur>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { switch (packet.CurencyType) { case 0: // SILVER TO GOLD lock (user) { int Total = (int)packet.Value * Settings.SILVER_EXCAHNGE_RATE; if (user.Silver < packet.Value) { netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = NOT_ENOUGH_SILVER }); return(true); } user.Silver -= (int)packet.Value; user.Gold += Total; DbService.SubmitUpdate2Queue(user); user.ResetNotification(); netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = SUCCESS, SilverValue = (uint)user.Silver, GoldValue = (uint)user.Gold }); return(true); } case 1: // GOLD TO SILVER lock (user) { int Total = (int)packet.Value * Settings.GOLD_EXCAHNGE_RATE; if (user.Gold < packet.Value) { netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = NOT_ENOUGH_GOLD }); return(true); } user.Gold -= (int)packet.Value; user.Silver += Total; user.ResetNotification(); DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = SUCCESS, SilverValue = (uint)user.Silver, GoldValue = (uint)user.Gold }); return(true); } } } else { //DO NOTHING return(true); } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } BuySkin packet = netMsg.ReadMessage <BuySkin>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { ConfiModel model = ConfigManager.GetModel((int)packet.ModelId); if (model == null) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = ITEM_CONFIG_WRONG }); return(true); } //Silver Buy if (packet.BuyType == 0) { //TO DO CHECK IF CHARACTER ALREADY HAS THE MODEL lock (user) { if (user.Silver < model.SilverPrice) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = NOT_ENOUGH_SILVER }); return(true); } Characters ccc = new Characters(user.Id, model.ModelId) { SkinColorId = model.SkinColorId, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, ShirtColorId = model.ShirtColorId, PantsColorId = model.PantsColorId, BootsColorId = model.BootsColorId, GlovesColorId = model.GlovesColorId }; ccc.PlayerId = DbService.SaveEntity(ccc); CharacterOBJ obj = new CharacterOBJ(ccc); user.Skins.Add(obj.PlayerId, obj); user.ResetNotification(); user.Silver -= model.SilverPrice; DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = SUCCESS, Gold = (uint)user.Gold, Silver = (uint)user.Silver, character = obj.GetServerChar() }); return(true); } } else // GOLD BUY { //TO DO CHECK IF CHARACTER ALREADY HAS THE MODEL lock (user) { if (user.Gold < model.GoldPrice) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = NOT_ENOUGH_GOLD }); return(true); } Characters ccc = new Characters(user.Id, model.ModelId) { SkinColorId = model.SkinColorId, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, ShirtColorId = model.ShirtColorId, PantsColorId = model.PantsColorId, BootsColorId = model.BootsColorId, GlovesColorId = model.GlovesColorId }; ccc.PlayerId = DbService.SaveEntity(ccc); CharacterOBJ obj = new CharacterOBJ(ccc); user.Skins.Add(obj.PlayerId, obj); user.Gold -= model.GoldPrice; DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = SUCCESS, Gold = (uint)user.Gold, Silver = (uint)user.Silver, character = obj.GetServerChar() }); return(true); } } } } return(true); }