コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: UserDB.cs プロジェクト: njfsilva/ChatServer
 public static bool LogUserInSystem(User user)
 {
     try
     {
         LoggedInUsers.Add(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #3
0
ファイル: UserDB.cs プロジェクト: njfsilva/ChatServer
 public static bool AddUser(User user)
 {
     try
     {
         UserDb.Add(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #4
0
ファイル: KeyMaster.cs プロジェクト: Entroper/WebSocketChat
        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();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: dingxiaowei/ProtobufCSharp
        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);
            }
        }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
 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;
 }
コード例 #9
0
        /// <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);
        }