public void BeCheckedOnline(string name) { while (ContinueToCheckOnline) { // fica travado até a seguinte tupla existir // caso exista, significa que alguem checou se esse usuario esta online _remotespace.Get("User", name, "ping"); // colocar a seguinte tupla para indicar que esta online _remotespace.Put("User", name, "ping", true); } }
public static bool SubscribeForLobby(string lobbyUrl) { string username = Connection.LocalPlayer.Name; int user_id = (int)Connection.LocalPlayer.Id; RemoteSpace lobbySpace = new RemoteSpace(lobbyUrl); lobbySpace.Get("lobby_lock"); ITuple playerTuple = lobbySpace.GetP("player", 0, "No user"); //Means that that there is no slots left in the lobby if (playerTuple == null) { lobbySpace.Put("lobby_lock"); return(false); } // Get lobby info (wasn't given with responsee) var lobbyTuple = Connection.GlobalSpace.Query("existingLobby", typeof(string), typeof(string), lobbyUrl); var ownerName = (string)lobbyTuple[2]; var ownerId = GetPlayerId(ownerName); Connection.Lobby = new Lobby(); Connection.Lobby.Space = lobbySpace; Connection.Lobby.Url = lobbyUrl; Connection.Lobby.Owner = new Player(ownerId, ownerName); Connection.Lobby.Id = (string)lobbyTuple[1]; lobbySpace.Put("player", user_id, username); lobbySpace.Put("lobby_lock"); return(true); }
private void CreateButton_Click(object sender, RoutedEventArgs e) { string newConferenceName = new TextRange(NewConferenceName.Document.ContentStart, NewConferenceName.Document.ContentEnd).Text.Trim(); if (!string.IsNullOrWhiteSpace(newConferenceName)) { var ipAddress = ProjectUtilities.IpFetcher.GetLocalIpAdress(); ConferenceRequests.Put(Username, newConferenceName, ipAddress, 1, RSA.RSAEncrypt(Password)); var feedback = ConferenceRequests.Get("Result", typeof(int), Username); if ((int)feedback[1] == 1) { ConferenceWindow conference = new ConferenceWindow(Username, newConferenceName, Password, ConferenceRequests, LoginSpace); App.Current.MainWindow = conference; conferenceListWindow.Close(); this.Close(); conference.Show(); } else { MessageBox.Show("Server rejected request. Try again, or log out and back in.", "Server fault", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); DataContext = conferenceListWindow; } } }
private string GetIpFromServer(string conferenceClicked) { ConferenceRequests.Put(Username, conferenceClicked, 0, RSA.RSAEncrypt(Password)); var temp = ConferenceRequests.Get(Username, typeof(string), typeof(int)); var ip = (string)temp[1]; return(ip); }
private bool authenticateLogin(string Username, string Password) { //string EncryptedPassword = ; loginSpace.Put(Username, RSA.RSAEncrypt(Password)); var result = loginSpace.Get(Username, typeof(int)); if (result != null) { if ((int)result[1] == 1) { return(true); } else { //handle wrong password return(false); } } else { //HANDLE LOGINSERVERERRORS return(false); } }
private bool AuthenticateAccountCreate(string Username, string Password) { //TEMPORARY MUST BE IMPLEMENTED AccountCreation.Put(Username, Password); var result = AccountCreation.Get(Username, typeof(int)); // await Task<ITuple>.Factory.StartNew(() => asyncGetresult(Username));// AccountCreation.GetP(Username, typeof(int)); if (result != null) { if ((int)result[1] == 1) { return(true); } else { //handle wrong password return(false); } } else { //HANDLE LOGINSERVERERRORS return(false); } }