Exemple #1
0
        public void RemoveUser(TcpSocket connectionInfo) => Task.Run(() => {
            if (!Exists(connectionInfo))
            {
                return;
            }

            Remove(this[connectionInfo]);
        }).Wait();
Exemple #2
0
        private void BeginAccepting()
        {
            Start();
            BeginAcceptTcpClient(ar => {
                try {
                    TcpSocket socket = new TcpSocket((( TcpListener )ar.AsyncState).EndAcceptTcpClient(ar));
                    ClientConnectionRequested?.Invoke(socket);
                } catch (ObjectDisposedException) { /* Is caused when exitting the server while still listening for new clients */ }

                BeginAccepting();
            }, this);
        }
Exemple #3
0
 public User(int id, string username, TcpSocket tcpConnectionInfo)
 {
     ID                = id;
     Username          = username;
     TcpConnectionInfo = tcpConnectionInfo;
 }
Exemple #4
0
 public User(string username, TcpSocket tcpConnectionInfo)
 {
     ID                = -1;
     Username          = username;
     TcpConnectionInfo = tcpConnectionInfo;
 }
Exemple #5
0
 public User(TcpSocket tcpConnectionInfo)
 {
     ID                = -1;
     Username          = "******";
     TcpConnectionInfo = tcpConnectionInfo;
 }
Exemple #6
0
 public bool Exists(TcpSocket connectionInfo) => this[connectionInfo] != null;
Exemple #7
0
 public void CreateTempUser(TcpSocket connectionInfo) => AddUser(new User(connectionInfo));
Exemple #8
0
 public void CreateUser(string username, TcpSocket connectionInfo) => AddUser(new User(username, connectionInfo));
Exemple #9
0
 public User this[TcpSocket connectionInfo] {
     get { try { return(_userList.First(u => u.TcpConnectionInfo == connectionInfo)); } catch (Exception) { return(null); } }
 }