Exemplo n.º 1
0
 private void Login(ClientController clientController, ProfileContainer profile)
 {
     if (_usersManager.IsRegistredUser(profile.UserName, profile.Password))
     {
         if (!_usersManager.IsConnectedUser(profile.UserName))
         {
             _usersManager.UpdateUserStatus(profile.UserName, true);
             _clients[IndexOfClient(clientController.IP, clientController.Port)].InLine = true;
             Console.WriteLine("Client {0} has been connected", profile.UserName);
             SendCommandToClient(clientController, new CommandContainer(CommandType.ValidCredentials, null));
             SendCommandToAllClients(clientController, new CommandContainer(CommandType.UsersConnectionStatus, new UsersStatusContainer(_usersManager.RegistredUsers.ClientsStatus)));
             SendCommandToAllClients(clientController, new CommandContainer(CommandType.RoomList, _roomsContainer));
             _usersManager.GetUserProfile(profile.UserName).LastConnected = DateTime.Now;
         }
         else
         {
             Console.WriteLine("Already connected client {0}", profile.UserName);
             SendCommandToClient(clientController, new CommandContainer(CommandType.UserAlreadyConnected, null));
         }
     }
     else
     {
         Console.WriteLine("Connection of client {0} refused", profile.UserName);
         SendCommandToClient(clientController, new CommandContainer(CommandType.InvalidCredentials, null));
     }
 }
Exemplo n.º 2
0
        private void StartReceive(object sender, DoWorkEventArgs e)
        {
            while (_socket.Connected)
            {
                // Read the command object.
                var bytes = new byte[8192];
                try
                {
                    var readBytes = _socket.Receive(bytes);
                    if (readBytes == 0)
                    {
                        break;
                    }
                    CommandContainer command = (CommandContainer)SerializerManager.Deserialize(bytes);

                    if ((command.CommandType == CommandType.ClientSignUp) || (command.CommandType == CommandType.ClientLogIn))
                    {
                        ProfileContainer profile = (ProfileContainer)command.Data;
                        _clientName = profile.UserName;
                    }

                    OnCommandReceived(new CommandEventArgs(command));
                }
                catch (Exception)
                {
                }
            }
            OnDisconnected(new ClientEventArgs(_socket));
            Disconnect();
        }
Exemplo n.º 3
0
 public static void SaveProfiles()
 {
     if (profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     profileContainer.Save(GetProfilesPath());
 }
        async void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e)
        {
            FieldContainer.TranslationX   = Width;
            FieldContainer.IsVisible      = true;
            ProfileContainer.TranslationY = 120;

            await Task.WhenAll(
                ProfileContainer.TranslateTo(ProfileContainer.TranslationX, 0, 400, easing: Easing.CubicInOut),
                FieldContainer.TranslateTo(0, FieldContainer.TranslationY, 400, easing: Easing.CubicInOut),
                Name.FadeTo(0, 400)
                );
        }
Exemplo n.º 5
0
 public static void AddToContainer(Profile aProfile)
 {
     if (profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     if (profileContainer.profiles.Find(x => x.name == aProfile.name) != null)
     {        //profile already exist, replace it by deleting old one
         profileContainer.profiles.Remove(profileContainer.profiles.Find(x => x.name == aProfile.name));
     }
     profileContainer.profiles.Add(aProfile);
 }
Exemplo n.º 6
0
 public static void AddToContainer( Profile aProfile )
 {
     if( profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     if( profileContainer.profiles.Find( x => x.name == aProfile.name ) != null )
     {//profile already exist, replace it by deleting old one
         profileContainer.profiles.Remove( profileContainer.profiles.Find(  x => x.name == aProfile.name ) );
     }
     profileContainer.profiles.Add( aProfile );
 }
Exemplo n.º 7
0
 private void RequestUserProfile(ClientController clientController, ProfileContainer profile)
 {
     if (_usersManager.IsRegistredUser(profile.UserName, profile.Password))
     {
         if (_usersManager.IsConnectedUser(profile.UserName))
         {
             ProfileContainer userProfile = _usersManager.GetUserProfile(profile.UserName);
             Console.WriteLine("Profile for user {0} has been found", userProfile.UserName);
             SendCommandToClient(clientController, new CommandContainer(CommandType.UserProfile, userProfile));
         }
     }
     else
     {
         Console.WriteLine("Profile {0} does not exist ", profile.UserName);
         //SendCommandToClient(clientController, new CommandContainer(CommandType.InvalidCredentials, null));
     }
 }
Exemplo n.º 8
0
 private void Logoff(ProfileContainer profile)
 {
     if (_usersManager.IsRegistredUser(profile.UserName, profile.Password))
     {
         if (_usersManager.IsConnectedUser(profile.UserName))
         {
             Console.WriteLine("Client {0} has been disconnected", profile.UserName);
         }
         else
         {
             Console.WriteLine("Client {0} has not been connected before", profile.UserName);
         }
     }
     else
     {
         Console.WriteLine("Disonnection of client {0} refused", profile.UserName);
     }
 }
Exemplo n.º 9
0
        private void SignUp(ClientController clientController, ProfileContainer newProfile)
        {
            var registrationStatus = _usersManager.RegisterNewUser(newProfile);

            if (registrationStatus == RegistrationStatus.Successful)
            {
                Console.WriteLine("New registred client {0}", newProfile.UserName);
                _clients[IndexOfClient(clientController.IP, clientController.Port)].InLine = true;
                SendCommandToClient(clientController, new CommandContainer(CommandType.ValidCredentials, null));
                SendCommandToAllClients(clientController, new CommandContainer(CommandType.UsersConnectionStatus, new UsersStatusContainer(_usersManager.RegistredUsers.ClientsStatus)));
                SendCommandToAllClients(clientController, new CommandContainer(CommandType.RoomList, _roomsContainer));
            }
            else
            {
                Console.WriteLine("Already registred client {0}", newProfile.UserName);
                SendCommandToClient(clientController, new CommandContainer(CommandType.UserAlreadyExists, null));
            }
        }
Exemplo n.º 10
0
 public static void LoadProfiles()
 {
     if (bWebBuild)
     {
         profileContainer          = new ProfileContainer();
         profileContainer.profiles = new List <Profile>();
         profileContainer.profiles.Add(Profile.Default());
     }
     else if (!bCheckedWebBuild)
     {
         GetProfilesPath();
         LoadProfiles();
     }
     else if (profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     profileContainer = profileContainer.Load(GetProfilesPath());
 }
Exemplo n.º 11
0
 public static void LoadProfiles()
 {
     if( bWebBuild )
     {
         profileContainer = new ProfileContainer();
         profileContainer.profiles = new List<Profile>();
         profileContainer.profiles.Add( Profile.Default() );
     }
     else if( ! bCheckedWebBuild )
     {
         GetProfilesPath();
         LoadProfiles();
     }
     else if( profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     profileContainer = profileContainer.Load( GetProfilesPath() );
 }
Exemplo n.º 12
0
        public RegistrationStatus RegisterNewUser(ProfileContainer newProfile)
        {
            var registrationStatus = RegistrationStatus.Successful;

            if (_profiles.Any(profile => profile.UserName.Equals(newProfile.UserName)))
            {
                registrationStatus = RegistrationStatus.AlreadyRegistred;
            }
            if (registrationStatus != RegistrationStatus.AlreadyRegistred)
            {
                newProfile.Connected = true;
                _profiles.Add(newProfile);
                using (Stream stream = File.Open(_fileName, FileMode.Create))
                {
                    var binaryFormatter = new BinaryFormatter();
                    binaryFormatter.Serialize(stream, _profiles);
                }
            }

            return(registrationStatus);
        }
Exemplo n.º 13
0
 public void Dispose()
 {
     _cookieJar = null;
     Profiles   = null;
     Id         = "";
 }
Exemplo n.º 14
0
        private void LoadNetflixProfilesTask()
        {
            var res = WebRequester.DoRequest(ApiVars.baseAPIUrl + Id + "/profiles", _cookieJar);

            Profiles = res.DeserializeResponse <ProfileContainer>();
        }
Exemplo n.º 15
0
 public static void SaveProfiles()
 {
     if( profileContainer == null)
     {
         profileContainer = new ProfileContainer();
     }
     profileContainer.Save( GetProfilesPath() );
 }
 public AchievementsCategoryController(ProfileContext context, AchievementsCategoryModel categoryModel, ProfileContainer categoryComponent)
 {
     _context           = context;
     _categoryModel     = categoryModel;
     _categoryComponent = categoryComponent;
 }