public void Button_Clicked(string buttonName) { if (buttonName == "LoginButton") { string EncryptedPW = PasswordUtil.MD5Password(PasswordTB.text); SFServer.Send(new LoginRequest(UsernameTB.text, EncryptedPW, GAME_ZONE)); } if (buttonName == "RegisterButton") { SFServer.Send(new LoginRequest("", "", GAME_ZONE)); this.RegisterPanel.SetActive(true); this.LoginPanel.SetActive(false); } if (buttonName == "ExitButton") { SFServer.Disconnect(); SFServer.RemoveAllEventListeners(); Application.Quit(); } if (buttonName == "CreateButton") { InputField UsernameTB = GameObject.Find("UsernameTB").GetComponent <InputField>(); InputField PasswordTB = GameObject.Find("PasswordTB").GetComponent <InputField>(); InputField ConfirmPasswordTB = GameObject.Find("ConfirmPasswordTB").GetComponent <InputField>(); InputField EmailTB = GameObject.Find("EmailTB").GetComponent <InputField>(); InputField RegistrationKeyTB = GameObject.Find("RegistrationKeyTB").GetComponent <InputField>(); if (PasswordTB.text == ConfirmPasswordTB.text) { SFSObject NewAccountObject = new SFSObject(); NewAccountObject.PutUtfString("Username", UsernameTB.text); NewAccountObject.PutUtfString("PasswordHash", PasswordTB.text); NewAccountObject.PutUtfString("Email", EmailTB.text); NewAccountObject.PutUtfString("RegistrationKey", RegistrationKeyTB.text); this.SFServer.Send(new ExtensionRequest("$SignUp.Submit", NewAccountObject)); } else { if (!MessageText.activeInHierarchy) { MessageText.SetActive(true); } MessageText.GetComponent <Text>().text = "Passwords do not match! Please check and try again."; } } if (buttonName == "BackButton") { this.LoginPanel.SetActive(true); this.RegisterPanel.SetActive(false); } }
public override void Execute(SmartFox sfs) { sfso.PutUtfString(KEY_ZONE_NAME, zoneName); sfso.PutUtfString(KEY_USER_NAME, userName); if (password.Length > 0) { password = PasswordUtil.MD5Password(sfs.SessionToken + password); } sfso.PutUtfString(KEY_PASSWORD, password); if (parameters != null) { sfso.PutSFSObject(KEY_PARAMS, parameters); } }
public void OnUpdateButtonClocked() { //on update button clicked, this values send to server to save them in DB int firstnameSpace, lastnameSpace; string password; Debug.Log("update account"); if (requredFilled()) //methos to check all required values filled { firstnameSpace = FirstName.text.IndexOf(" "); lastnameSpace = LastName.text.IndexOf(" "); if (firstnameSpace == -1 && lastnameSpace == -1) //to make sure that names do not contains spaces { if (View_Password.text == ConPassword.text) ////to make sure that password and its confirm match { ISFSObject objOut = new SFSObject(); if (pass == View_Password.text) { password = pass; //if password not change, take it as it is } else { password = PasswordUtil.MD5Password(View_Password.text); //if password changed, encrypt it } objOut.PutUtfString("username", username); objOut.PutUtfString("account", "Admin"); objOut.PutUtfString("password", password); objOut.PutUtfString("firstName", FirstName.text); objOut.PutUtfString("lastName", LastName.text); objOut.PutUtfString("biography", Biography.text); NetworkManager.Instance.UpdateAccount(objOut); } else //error mesages "not maching passwords" { TextMessage.text = "The password and its confirm are not matching"; } } else //error mesages "spaces in names" { TextMessage.text = "firstname & lastname should not contains a space"; } } else //error mesages "missing required values" { TextMessage.text = "Missing to fill required value"; } }
//-----------------------------------------------------------------------OnConnection private void OnConnection(BaseEvent evt) { if ((bool)evt.Params["success"]) { // Login Debug.Log("Successfully Connected!"); password = PasswordUtil.MD5Password(password); //to incrypt the password //added by wed to anable networking SmartFoxConnection.Connection = sfs; sfs.Send(new LoginRequest(username, password, ZoneName)); } else { Debug.Log("Connection Failed!"); // Remove SFS2X listeners and re-enable interface reset(); // Show error message TextMessage.text = "Connection Failed!"; } }
private void OnExtensionResponse(BaseEvent evt) { Debug.Log("2"); string cmd = (string)evt.Params["cmd"]; ISFSObject objIn = (SFSObject)evt.Params["params"]; string message; if (cmd == CMD_Signup) { Debug.Log("3"); if (objIn.ContainsKey("success")) { message = "Signup Successful"; Debug.Log(message); TextMessage.text = message; } else { Error = 1; message = objIn.GetUtfString("errorMessage"); message = "Signup Error: " + message; Debug.Log(message); TextMessage.text = message; reset(); } } else if (Error == 0 && Act_Room == "Y" && CreateRoom == 0) { ISFSArray Rooms = objIn.GetSFSArray("Rooms"); int length = Rooms.Size(); Debug.Log("length : " + length); if (length < RoomsNum) { int i; if (length > 0) { for (int j = 1; j <= length; j++) { for (i = 1; i <= length; i++) { if (j == int.Parse(Rooms.GetSFSObject(i - 1).GetUtfString("Room_ID"))) { break; } } if (i == length) { Room_ID = j + 1; break; } else if (i > length) { Room_ID = j; break; } } } CreateRoom = 1; Debug.Log("activate room"); Room room = new Room(); room.createRoom(sfs, Room_ID, username, Account_T); } else { TextMessage2.text = "The account has been created successfully, But your room has not been created; since there is not any empty room."; updateAccount = 1; ISFSObject objOut = new SFSObject(); Act_Room = "N"; password = PasswordUtil.MD5Password(password);//to incrypt the password objOut.PutUtfString("username", username); objOut.PutUtfString("account", "member"); objOut.PutUtfString("password", password); objOut.PutUtfString("email", email); objOut.PutUtfString("firstName", firstname); objOut.PutUtfString("lastName", lastname); objOut.PutUtfString("biography", biography); objOut.PutUtfString("hasRoom", Act_Room); objOut.PutUtfString("accountType", Account_T); objOut.PutUtfString("avatar", Avt); sfs.Send(new ExtensionRequest("UpdateAccount", objOut)); } } else if (Error == 0 && Act_Room == "Y" && CreateRoom == 1) { CreateRoom = 0; string result = objIn.GetUtfString("CreateRoomResult"); if (result == "Successful") { Debug.Log("Successful"); TextMessage2.text = "The account has been created successfully. Your room Id is " + Room_ID; } else { Debug.Log("error"); } } else if (Error == 0 && updateAccount == 1) { string result = objIn.GetUtfString("UpdateResult"); if (result == "Successful") { Debug.Log("Successful"); } else { Debug.Log("error"); } updateAccount = 0; } if (Error == 0) { Result.gameObject.SetActive(true); createAccount.gameObject.SetActive(false); } }
public void OnUpdateButtonClocked() { //on update button clicked, this values send to server to save them in DB int firstnameSpace, lastnameSpace; string Act_Room, Avt, Account_T, password; Debug.Log("update account"); if (requredFilled())//methos to check all required values filled { firstnameSpace = FirstName.text.IndexOf(" "); lastnameSpace = LastName.text.IndexOf(" "); if (firstnameSpace == -1 && lastnameSpace == -1)//to make sure that names do not contains spaces { if (View_Password.text == ConPassword.text)////to make sure that password and its confirm match { ISFSObject objOut = new SFSObject(); if (ActivateRoom.isOn == true)//store activate room request Act_Room = "Y"; else Act_Room = "N"; if (AccountType.isOn == true)//store accout type request Account_T = "private"; else Account_T = "public"; if (FAvatar.isOn == true) //store avatar gender Avt = "F"; else Avt = "M"; if (pass == View_Password.text) password = pass;//if password not change, take it as it is else password = PasswordUtil.MD5Password(View_Password.text);//if password changed, encrypt it Room[] rooms = Transverser.Rooms;//get rooms from class Transverser store all rooms in city in rooms array int length = rooms.Length; Debug.Log("length : " + length); TextMessage.text = ""; if (length == RoomsNum && previousHasRoom == "N" && Act_Room == "Y") { Act_Room = "N";//since there no empty room TextMessage.text ="Sorry, your request to have room did not activated, since there is not any empty room.\n"; //EditorUtility.DisplayDialog("Waring Message", "Sorry, there is not any empty room.", "ok"); } objOut.PutUtfString("username", username);//store username objOut.PutUtfString("account", "member");//user type objOut.PutUtfString("password", password);//store password objOut.PutUtfString("firstName", FirstName.text);//store first name objOut.PutUtfString("lastName", LastName.text);//store last name objOut.PutUtfString("biography", Biography.text);//store bio objOut.PutUtfString("hasRoom", Act_Room);//store has room request or not objOut.PutUtfString("accountType", Account_T);//store account type (private , public) objOut.PutUtfString("avatar", Avt);//store avatar gender NetworkManager.Instance.UpdateAccount(objOut);//send them to server if (Avt == "M")//acctivate choosen avatar { BoyAvatar.gameObject.SetActive(true); GirlAvatar.gameObject.SetActive(false); } else { BoyAvatar.gameObject.SetActive(false); GirlAvatar.gameObject.SetActive(true); } if (length < RoomsNum && previousHasRoom == "N" && Act_Room == "Y") {//if there is an empty room Debug.Log("activate room"); int i; if (length > 0)//to find room id for (int j = 1; j <= length; j++) { for (i = 1; i <= length; i++) { if (j == rooms[i - 1].getRoomId()) break; } if (i == length) { Room_ID = j + 1; break; } else if (i > length) { Room_ID = j; break; } } Debug.Log("activate room"); Room room = new Room(); room.CreateRoom(Room_ID, username, Account_T);//to create room } else if (previousHasRoom == "Y" && Act_Room == "N") { Debug.Log("delete room"); Room room = new Room(); room.DeleteRoom(username);//to delete room } } else TextMessage.text = "The password and its confirm are not matching"; } else TextMessage.text = "firstname & lastname should not contains a space"; } else TextMessage.text = "Missing to fill required value"; }
// Update is called once per frame //---------------------------------------------------------- // Public interface methods for UI //---------------------------------------------------------- public void OnCreateAccountButtonClicked() { //on create account button clicked int usernameSpace, firstnameSpace, lastnameSpace; username = UserName.text; //store username usernameSpace = username.IndexOf(" "); //get space index password = Password.text; //store password Conpassword = ConPassword.text; //store confirm password email = Email.text; //store email biography = Biography.text; //store bio firstname = FirstName.text; //store first name firstnameSpace = firstname.IndexOf(" "); //get space index lastname = LastName.text; //store last name lastnameSpace = lastname.IndexOf(" "); //get space index if (requredFilled()) //method to check all required values filled { //to prevent spaces in names if (usernameSpace == -1 && firstnameSpace == -1 && lastnameSpace == -1) { //check password and its confirm are matching if (password == Conpassword) { ///validate eamil if (email.IndexOf("@") != -1) { // method to Enable interface enableInterface(false); ISFSObject objOut = new SFSObject(); int AdminIndex = username.IndexOf("n"); //get "n" index string admin = username.Substring(0, AdminIndex + 1); //to check that all admin username start with "Admin" if (admin.Equals("admin")) { username = "******" + username.Substring(1); } else if (!admin.Equals("Admin")) { username = "******" + username; } password = PasswordUtil.MD5Password(password); //to incrypt the password objOut.PutUtfString("username", username); //set username objOut.PutUtfString("password", password); //set password objOut.PutUtfString("email", email); //set email objOut.PutUtfString("firstName", firstname); //set firstname objOut.PutUtfString("lastName", lastname); //set lastname objOut.PutUtfString("biography", biography); //set bio objOut.PutUtfString("isAdmin", "Y"); //set the account is admin NetworkManager.Instance.AddNewAdmin(objOut); //send request to server } else//error message "invali email" { TextMessage.text = "Invalid email account"; } } else //error message "password and its confirm are not matching" { TextMessage.text = "The password and its confirm are not matching"; } } else//error message "spaces in names" { TextMessage.text = "Username,firstname & lastname should not contains a space"; } } else //error message"missing values" { TextMessage.text = "Missing to fill required value"; } }//end create account