/// <summary>
        /// Event fired when a client connects to the Alchemy Websockets server instance.
        /// Adds the client to the online users list.
        /// </summary>
        /// <param name="context">The user's connection context</param>
        public static void OnConnect(UserContext context)
        {
            Console.WriteLine("Client Connection From : " + context.ClientAddress);

            var me = new User {Context = context};

            OnlineUsers.TryAdd(me, String.Empty);
        }
Beispiel #2
0
 public static bool LogUserInSystem(User user)
 {
     try
     {
         LoggedInUsers.Add(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #3
0
 public static bool AddUser(User user)
 {
     try
     {
         UserDb.Add(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #4
0
        public void CreateUser(string name, string password)
        {
            byte[] salt = new byte[PBKDF2_SHA256.StateSize];
            rng.GetBytes(salt);
            var hasher = new PBKDF2_SHA256(password, salt, IterationCount);

            var user = new User();
            user.Name = name;
            user.PasswordHash = hasher.GetBytes(PBKDF2_SHA256.StateSize * 2);
            user.PasswordSalt = (byte[])salt.Clone();

            container.Users.AddObject(user);
            container.SaveChanges();
        }
Beispiel #5
0
        static void ReturnAccept(IAsyncResult ar)
        {
            try
            {
                Console.WriteLine("Star AcceptCallBack");

                TcpListener Server = (TcpListener)ar.AsyncState;
                TcpClient client = Server.EndAcceptTcpClient(ar);

                var usr = new User(client);
                usr.Welcome();

                Server.BeginAcceptTcpClient(new AsyncCallback(ReturnAccept), Server);
            }catch( Exception  ex){
                Console.WriteLine("accept async exception:{0} ", ex.Message);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="passwordHash">Initial value of the PasswordHash property.</param>
 /// <param name="passwordSalt">Initial value of the PasswordSalt property.</param>
 public static User CreateUser(global::System.Int32 userID, global::System.String name, global::System.Byte[] passwordHash, global::System.Byte[] passwordSalt)
 {
     User user = new User();
     user.UserID = userID;
     user.Name = name;
     user.PasswordHash = passwordHash;
     user.PasswordSalt = passwordSalt;
     return user;
 }
 public bool newRegistration(String login, String password)
 {
     using (UserContext db = new UserContext())
     {
             var users = db.Users;
             foreach (User u in users)
             {
                 if (u.login == login)
                     return false;
             }
             User newUser = new User { login = login, password = password };
             db.Users.Add(newUser);
             db.SaveChanges();
     }
     return true;
 }
        /// <summary>
        /// Event fired when a client connects to the Alchemy Websockets server instance.
        /// Adds the client to the online users list.
        /// </summary>
        /// <param name="AContext">The user's connection context</param>
        public static void OnConnect(UserContext AContext)
        {
            Console.WriteLine("Client Connection From : " + AContext.ClientAddress.ToString());

            User me = new User();
            me.Context = AContext;

            OnlineUsers.Add(me);
        }