public LoginModel() : base() { ServiceRegistry.Register<LoginModel>(this); Client = new LoginClient(); }
public Trivia_Lobby(string username) { InitializeComponent(); dh = new DataHandler(); //we pass the username from form1 to this form user = username; proxy = new LoginClient(); }
public static void FileHash(LoginClient pClient, Packet pPacket) { string hash; if (!pPacket.TryReadString(out hash)) { Log.WriteLine(LogLevel.Warn, "Empty filehash received."); SendFailedLogin(pClient, ServerError.Exception); } else AllowFiles(pClient, true); }
public MapServer(int worldID,string IP,short port, LoginClient sClient, int[] hostedMaps, int playerOnline, byte ping) { this.sClient = sClient; this.worldID = worldID; this.IP = IP; this.port = port; this.hostedMaps = hostedMaps; this.playerOnline = playerOnline; this.ping = ping; lastPing = DateTime.Now; lastPong = DateTime.Now; }
protected override void OnDispose() { ServiceRegistry.GetService<AudioService>().StopMusic(); ServiceRegistry.Unregister<LoginModel>(); Client.Dispose(); Client = null; m_UserInterface.Reset(); m_SceneManager.CurrentState = null; m_SceneManager = null; }
/// <summary> /// Login to the login server. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public bool Login(string username, string password) { if (lc != null) lc.Dispose(); lc = new LoginClient(5, protocolVersion); lc.LoginDisconnected += new LoginClientEvent(HandleDisconnectEvent); lc.LoginConnected += new LoginClientEvent(HandleConnectEvent); if (lc.Connect(host, port)) { State = LoginConnectionState.ConnectedToLogin; if (lc.Login(username, password)) { State = LoginConnectionState.WorldListReceived; worldList = lc.WorldServers; accountId = lc.AccountId; } else { disconnectMessage = "Unable to login."; State = LoginConnectionState.Disconnected; lc.Dispose(); } } else { disconnectMessage = "Unabe to connect."; State = LoginConnectionState.Disconnected; lc.Dispose(); } return (state == LoginConnectionState.WorldListReceived); }
public MapHeartbeat(LoginClient client) { this.dueTime = 1000; this.period = 60000; this.client = client; }
private void OnClick(object sender, EventArgs e) { LoginClient client = new LoginClient(new BasicHttpBinding(), new EndpointAddress("http://localhost:63853/wcf/login.svc")); client.LogarCompleted += OnLogar; client.LogarAsync(_txtUsername.Text, _txtPassword.Text); }
public static void WorldSelectHandler(LoginClient pClient, Packet pPacket) { if (!pClient.IsAuthenticated || pClient.IsTransferring) { Log.WriteLine(LogLevel.Warn, "Invalid world select request."); SendFailedLogin(pClient, ServerError.Exception); return; } byte id; if (!pPacket.TryReadByte(out id)) { Log.WriteLine(LogLevel.Warn, "Invalid world select."); return; } WorldConnection world; if (WorldManager.Instance.Worlds.TryGetValue(id, out world)) { switch (world.Status) { case WorldStatus.Maintenance: Log.WriteLine(LogLevel.Warn, "{0} tried to join world in maintentance.", pClient.Username); SendFailedLogin(pClient, ServerError.ServerMaintenance); return; case WorldStatus.Offline: Log.WriteLine(LogLevel.Warn, "{0} tried to join offline world.", pClient.Username); SendFailedLogin(pClient, ServerError.ServerMaintenance); return; default: Log.WriteLine(LogLevel.Debug, "{0} joins world {1}", pClient.Username, world.Name); break; } string hash = System.Guid.NewGuid().ToString().Replace("-", ""); world.SendTransferClientFromWorld(pClient.AccountID, pClient.Username, pClient.Admin, pClient.Host, hash); Log.WriteLine(LogLevel.Debug, "Transferring login client {0}.", pClient.Username); pClient.IsTransferring = true; SendWorldServerIP(pClient, world, hash); } else { Log.WriteLine(LogLevel.Warn, "{0} selected invalid world.", pClient.Username); return; } }
public static void VersionInfo(LoginClient pClient, Packet pPacket) { ushort year; ushort version; if (!pPacket.TryReadUShort(out year) || !pPacket.TryReadUShort(out version)) { Log.WriteLine(LogLevel.Warn, "Invalid client version."); pClient.Disconnect(); return; } Log.WriteLine(LogLevel.Debug, "Client version authenticated - Year: {0} Version: {1}.", year, version); using (Packet response = new Packet(SH3Type.VersionAllowed)) { response.WriteShort(1); pClient.SendPacket(response); } }
public override void OnClientConnect(Socket socket) { LoginClient client = new LoginClient(socket); ClientManager.Instance.AddClient(client); Log.WriteLine(LogLevel.Debug, "Client connected from {0}", client.Host); }
public void SendPlayer(byte serverId, LoginClient client, string time) { L2Server server = Servers.FirstOrDefault(srv => (srv.Id == serverId) && (srv.Thread != null)); server?.Thread.SendPlayer(client, time); }
public void setClient(LoginClient connection) { this._connection = connection; }
public AuthGameGuard(Packet p, LoginClient client) { _client = client; _sessionId = p.ReadInt(); }
public BASE_USER_CONFIGS_REC(LoginClient client, byte[] data) { makeme(client, data); }
public opcode_2667_REQ(LoginClient lc, byte[] buff) { this.makeme(lc, buff); }
private void DoLogin(LoginData data) { Hide(); try { LoginClient = data.Login(Login); SettingsManager.LoginDatas.Remove(data); SettingsManager.LoginDatas.Insert(0, data); SettingsManager.Save(); Close(); } catch (Exception ex) { Show(); MessageBox.Show("Unable to login: "******"Error!"); } }
private void DoLogin(string facebookToken) { Hide(); try { LoginClient = Login.WithFacebook(facebookToken); Close(); } catch (Exception ex) { Show(); MessageBox.Show("Unable to login: "******"Error!"); } }
static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += (sender, e) => EndLog(); GameString.Load("..\\..\\res", "zh", "en"); PBOServer.NewServer(9999); Thread.Sleep(1000); RoomController.GameStop += (r, u) => LogLine(r.ToString() + (u == null ? " " : " " + u.Name)); LoginClient.LoginSucceed += (c) => { switch (c.Controller.User.Name) { case "P00": C00 = new TestClient(c.Controller, Seat.Player00); C00.C.NewRoom(new GameSettings(GameMode.Multi)); break; case "P01": C01 = new TestClient(c.Controller, Seat.Player01); break; case "P10": C10 = new TestClient(c.Controller, Seat.Player10); break; case "P11": C11 = new TestClient(c.Controller, Seat.Player11); break; } Console.WriteLine(c.Controller.User.Name + "logined."); }; var l00 = new LoginClient("127.0.0.1", 9999, "P00", 1); var l01 = new LoginClient("127.0.0.1", 9999, "P01", 1); var l10 = new LoginClient("127.0.0.1", 9999, "P10", 1); var l11 = new LoginClient("127.0.0.1", 9999, "P11", 1); l00.BeginLogin(); l01.BeginLogin(); l10.BeginLogin(); l11.BeginLogin(); Console.ReadKey(); TEAM: C00.EditTeam(null); C01.EditTeam(C00.Team); C10.EditTeam(C01.Team); C11.EditTeam(C10.Team); LogLine("============BATTLE============"); BATTLE: Thread.Sleep(500); if (C00.Battle() && C01.Battle() && C10.Battle() && C11.Battle()) { goto BATTLE; } else { Console.WriteLine("------------------------------"); EndLog(); goto TEAM; } }
public bool CheckOnline(string ID, LoginClient my) { uint session = 0; List<LoginClient> list = new List<LoginClient>(); foreach (LoginClient i in this.clients.Values) { if (i.User != null) { if (i.User.Name.ToLower() == ID.ToLower()) { if (my != i) list.Add(i); } } if (session != 0) break; } if (list.Count == 0) return false; else { foreach (LoginClient i in list) { i.Disconnect(); } return true; } }
/// <summary> /// Spawns a temp mob on a worldmap /// </summary> /// <param name="client"></param> /// <param name="input"></param> //[ChatCmdAttribute("spawncircle", "spawncircle <name> <displayid>")] static bool OnSpawnCircle(LoginClient client, string input) { if (client.Account.AccessLvl < ACCESSLEVEL.GM) { Chat.System(client, "You do not have access to this command"); return(true); } string[] split = input.Split('\"'); if (split.Length == 3) { split[2] = split[2].TrimStart(' '); } else if (split.Length == 1) { split = input.Split(' '); } if (split.Length != 3) { return(false); } int displayID = 0; try { if (split[2].StartsWith("0x")) { displayID = int.Parse(split[2].Substring(2), System.Globalization.NumberStyles.HexNumber); } else { displayID = int.Parse(split[2]); } } catch (Exception) { return(false); } if (displayID == 0) { Chat.System(client, "You must set a displayID."); return(true); } string name = split[1]; name = name.Replace("'", ""); // bleh!! if (name.Length > 20) { name = name.Substring(0, 20); } DataObject[] objs; try { objs = DataServer.Database.SelectObjects(typeof(DBCreature), "Name = '" + name + "'"); } catch (Exception) { Chat.System(client, "Error looking up name in database."); return(true); } DBCreature creature; if (objs.Length == 0) { creature = new DBCreature(); creature.Name = name; DataServer.Database.AddNewObject(creature); } else { creature = (DBCreature)objs[0]; } client.WorldConnection.Send(creature); ScriptPacket pkg = new ScriptPacket(SCRMSG.SPAWNCIRCLE); pkg.Write(client.Character.ObjectId); pkg.Write(creature.ObjectId); pkg.Write(displayID); client.WorldConnection.Send(pkg); return(true); }
public LoginModel() { Service.Add(this); Client = new LoginClient(); }
private static void AllowFiles(LoginClient pClient, bool pIsOk) { using (Packet pack = new Packet(SH3Type.FilecheckAllow)) { pack.WriteBool(pIsOk); pClient.SendPacket(pack); } }
public static void WorldReRequestHandler(LoginClient pClient, Packet pPacket) { if (!pClient.IsAuthenticated) { Log.WriteLine(LogLevel.Warn, "Invalid world list request."); return; } WorldList(pClient, true); }
private static void SendFailedLogin(LoginClient pClient, ServerError pError) { using (Packet pack = new Packet(SH3Type.Error)) { pack.WriteUShort((ushort)pError); pClient.SendPacket(pack); } }
public BASE_LOGIN_REC(LoginClient client, byte[] data) { makeme(client, data); }
private static void WorldList(LoginClient pClient, bool pPing) { using (var pack = new Packet(pPing ? SH3Type.WorldistResend : SH3Type.WorldlistNew)) { pack.WriteByte(11);//worldmax count //pack.WriteByte((byte)WorldManager.Instance.WorldCount); foreach (var world in WorldManager.Instance.Worlds.Values) { pack.WriteByte(world.ID); pack.WriteString(world.Name, 16); pack.WriteByte((byte)world.Status); } for (int i = 0; i < (11 - WorldManager.Instance.Worlds.Count); i++) { pack.WriteByte((byte)i); pack.WriteString("DUMMY" + i, 16); pack.WriteByte((byte)WorldStatus.Offline); } pClient.SendPacket(pack); } }
private static void InvalidClientVersion(LoginClient pClient) { using (Packet pack = new Packet(SH3Type.IncorrectVersion)) { pack.Fill(10, 0); pClient.SendPacket(pack); } }
public RequestAuthLogin(Packet p, LoginClient client) { _client = client; Raw = p.ReadByteArrayAlt(128); }
private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash) { using (var pack = new Packet(SH3Type.WorldServerIP)) { pack.WriteByte((byte)wc.Status); pack.WriteString(wc.IP, 16); Log.WriteLine(LogLevel.Warn, "{0} - IP", wc.IP); pack.WriteUShort(wc.Port); pack.WriteString(hash, 32); pack.Fill(32, 0); pClient.SendPacket(pack); } }
public Account(LoginClient client) { this.Client = client; }
public static void Login(LoginClient pClient, Packet pPacket) { // Initialize DB DatabaseClient dbClient = Program.DatabaseManager.GetClient(); // XX XX XX XX XX XX XX XX XX XX XX - login length // 00 00 00 00 00 00 00 - space // XX XX XX XX XX XX XX - password // 00 00 00 00 00 00 00 00 00 4F 72 69 67 69 6E 61 6C 00 00 00 00 00 00 00 00 00 00 00 // Define packet lengths, as these may change with client updates int packetLength = 54; int loginBlock = 11; int spaceLength = 7; int passwordBlock = 7; string md5 = pPacket.ReadStringForLogin(packetLength); char[] md5Char = md5.ToCharArray(); string username = ""; string clientPassword = ""; // TODO - Escape these before query processing // Read from 0 --> 11 for (int i = 0; i <= loginBlock; i++) username += md5Char[i].ToString().Replace("\0", ""); Log.WriteLine(LogLevel.Debug, "{0} tries to login.", username); // Read from 18 --> onwards for (int i = loginBlock + spaceLength; i <= loginBlock + spaceLength + passwordBlock; i++) clientPassword += md5Char[i].ToString().Replace("\0", ""); Log.WriteLine(LogLevel.Debug, "{0} tries to login.", clientPassword); DataTable loginData = null; using (dbClient) loginData = dbClient.ReadDataTable("SELECT * FROM accounts WHERE Username= '******'"); // Auto account creation if no username found if (loginData.Rows.Count == 0) { dbClient.ExecuteQuery("INSERT INTO accounts (username, password) VALUES ('" + username + "','" + clientPassword + "')"); using (dbClient) loginData = dbClient.ReadDataTable("SELECT * FROM accounts WHERE Username= '******'"); } if (loginData != null) { if (loginData.Rows.Count > 0) { foreach (DataRow row in loginData.Rows) { string uIsername = (string)row["username"]; string password = (string)row["password"]; bool banned = Database.DataStore.ReadMethods.EnumToBool(row["banned"].ToString()); if (clientPassword == password) { if (banned) { SendFailedLogin(pClient, ServerError.Blocked); Log.WriteLine(LogLevel.Debug, "Banned user - {0} tries to login.", username); } else if (ClientManager.Instance.IsLoggedIn(uIsername)) { Log.WriteLine(LogLevel.Warn, "{0} is trying dual login. Disconnecting.", uIsername); pClient.Disconnect(); break; } else { pClient.Username = uIsername; pClient.IsAuthenticated = true; pClient.Admin = 0; /*(byte)row["Admin"];*/ pClient.AccountID = int.Parse(row["id"].ToString()); WorldList(pClient, false); } } else SendFailedLogin(pClient, ServerError.InvalidCredentials); } } } }
public AuthGameGuard(IServiceProvider serviceProvider, Packet p, LoginClient client) : base(serviceProvider) { _client = client; _sessionId = p.ReadInt(); }
public Register() { InitializeComponent(); dh = new DataHandler(); proxy = new LoginClient(); }
public async Task <string> SignInWithTokenAsync(User storedUser, bool fireEvents = true) { try { LoggerService.Instance.Log("Account.SignInWithTokenAsync..."); IsLoading = true; UserInfo = null; if (storedUser == null) { LoggerService.Instance.Log("ERROR: Account.SignInWithTokenAsync: cannot get stored account"); var error = "There was an error logging in"; if (fireEvents) { await Fire_OnSignInComplete(SignedIn, error, false, SignInAErrorType.LoginError); } return(error); } if (!storedUser.IsTokenExpired()) { LoggerService.Instance.Log("Account.SignInWithTokenAsync: account token NOT expired. reusing it"); UserInfo = storedUser; await FetchUserCreditsAsync(); if (fireEvents) { await Fire_OnSignInComplete(SignedIn, null, false, SignInAErrorType.LoginError); } return(null); } var errorMessage = string.Empty; var response = await LoginClient.LoginWithToken(storedUser.AuthToken); if (response != null) { if (response.Success) { var newUser = response.Data.ToObject <User>(); newUser.Name = newUser.FirstName + "" + userInfo.LastName; if (!string.IsNullOrEmpty(newUser.Token)) { newUser.AuthToken = storedUser.AuthToken; UserInfo = newUser; await FetchUserCreditsAsync(); UserStoreService.Instance.SaveUserCredentials(newUser); } else { LoggerService.Instance.Log("ERROR: Account.SignInWithTokenAsync: token is null"); errorMessage = "There was an error logging in"; } } else if (response.ErrorCode == ErrorCodes.AUTH_TOKEN_LOGIN) { //The auth token must be invalid - reset user info and request input storedUser.Token = null; storedUser.AuthToken = null; UserInfo = null; UserStoreService.Instance.SaveUserCredentials(storedUser); errorMessage = response.ErrorMessageClean; } else { errorMessage = response.ErrorMessageClean; } } else { errorMessage = "There was an error logging in"; } if (!string.IsNullOrEmpty(errorMessage)) { LoggerService.Instance.Log("ERROR: Account.SignInWithTokenAsync: " + errorMessage); } else { LoggerService.Instance.Log("Account.SignInWithTokenAsync: success"); } OnPropertyChanged("SignedIn"); if (fireEvents) { await Fire_OnSignInComplete(SignedIn, errorMessage, false, SignInAErrorType.LoginError); } return(errorMessage); } catch (ThrottleException ex) { return(ex.Message); } finally { IsLoading = false; } }
public async Task SignInAsync(string userName, string userPassword) { try { LoggerService.Instance.Log("Account.SignInAsync..."); IsLoading = true; UserInfo = null; var errorMessage = string.Empty; var response = await LoginClient.LoginWithCredentials(userName, userPassword); if (response != null) { if (response.Success) { var newUser = response.Data.ToObject <User>(); if (!string.IsNullOrEmpty(newUser.Token)) { UserInfo = newUser; newUser.Password = userPassword; await FetchUserCreditsAsync(); UserStoreService.Instance.SaveUserCredentials(UserInfo); } else { LoggerService.Instance.Log("ERROR: Account.SignInAsync: token is null"); errorMessage = "There was an error logging in"; } } else { errorMessage = response.ErrorMessageClean; } } else { errorMessage = "There was an error logging in"; } if (!string.IsNullOrEmpty(errorMessage)) { LoggerService.Instance.Log("ERROR: Account.SignInAsync: " + errorMessage); } else { LoggerService.Instance.Log("Account.SignInAsync: success"); } OnPropertyChanged("SignedIn"); await Fire_OnSignInComplete(SignedIn, errorMessage, false, SignInAErrorType.LoginError); } catch (ThrottleException ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { IsLoading = false; } }
public void Dispose() { try { if (lc != null) lc.Dispose(); lc = null; } finally { State = LoginConnectionState.Disconnected; } }