Esempio n. 1
0
        // For TcpListener Handling.
        public static PeerConnection AcceptConnectionFromTcpListener(string ThisPeerID, TcpListener Listener)
        {
            PeerConnection r = null;

            if (Listener.Pending())
            {
                TcpClient ConnectedSocket = Listener.AcceptTcpClient();
                ConnectedSocket.ReceiveTimeout = 5;
                ConnectedSocket.SendTimeout    = 5;
                r = new PeerConnection(ThisPeerID);
                r.BeginConnect(ConnectedSocket);
                r.OwnsSocket = true;
            }
            return(r);
        }
Esempio n. 2
0
        public void RunCycle(float DeltaTime)
        {
            foreach (PeerConnection item in _PendingConnections.ToArray())
            {
                item.RunCycle(DeltaTime);

                // Clean up the connections that finished being rejected or was lost.
                if (item.ConnectionStatus == 0)
                {
                    _PendingConnections.Remove(item);
                    item.Dispose();
                }
            }
            if (_Active)
            {
                while (_Listener.Pending())
                {
                    PeerConnection NewConnection = PeerConnection.AcceptConnectionFromTcpListener(LocalIdentity, _Listener);
                    NewConnection.AutoSendGreeting = false; // Specifically for enabling user request scrutiny.
                    _PendingConnections.Add(NewConnection);
                }
            }
        }
Esempio n. 3
0
        public void RunCycle(float DeltaTime)
        {
            if (_Active)
            {
                while (_ListenerSocket.Pending())
                {
                    PeerConnection NewConnection = PeerConnection.AcceptConnectionFromTcpListener("Some Guy's Server", _ListenerSocket);
                    ClientInfo     NewClient     = new ClientInfo(this, NewConnection, _NextGuestId);
                    _Clients.Add(NewClient);
                    Log_Write_System(string.Format("A new guest has connected! It was assigned an ID of {0}.", _NextGuestId));

                    _NextGuestId++;
                }
            }
            foreach (ClientInfo item in _Clients.ToArray())
            {
                item.C.RunCycle(DeltaTime);
                foreach (string m in item.C.Log_CollectOutput())
                {
                    Log_Write(m);
                }
            }
            CheckOnClients();
        }
Esempio n. 4
0
 public ClientInfo(ChatServer ParentServer, PeerConnection Connection, int Id)
 {
     this.ParentServer = ParentServer;
     this.C            = Connection;
     this.ID           = Id;
 }