示例#1
0
        private void Accept(IAsyncResult iAr)
        {
            Socket s = null;
            try
            {
                s = socket.EndAccept(iAr);
                Log.WriteLine("New connection from " + s.RemoteEndPoint.ToString());
                User usr = new User(s);
            }
            catch { try { s.Close(); } catch { } } // Force close the socket when an exception is triggered here to avoid ghost sockets.

            if (socket != null)
            {
                socket.BeginAccept(new AsyncCallback(this.Accept), null);
            }
        }
示例#2
0
        public void Deserialize(byte[] data, Pointer p)
        {
            AllowRemoteConnections = BitPacker.GetBool(data, p);
            TotalUserCount = BitPacker.GetInt(data, p);
            UserDataStore = BitPacker.GetString(data, p);

            int count = BitPacker.GetInt(data, p);
            for (int i = 0; i < count; i++)
            {
                string username = BitPacker.GetString(data, p);
                string[] roles = BitPacker.GetStringList(data, p).ToArray();
                bool isLocked = BitPacker.GetBool(data, p);
                Guid id = new Guid(BitPacker.GetString(data, p));
                string email = BitPacker.GetString(data, p);
                DateTime lastLogin = new DateTime(BitPacker.GetLong(data, p), DateTimeKind.Utc);
                User urs = new User(username, roles, isLocked, id, email, lastLogin);
                Users.Add(urs);
            }
        }