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

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