Esempio n. 1
0
        public void CheckForNewClient()
        {
            if (!CanListen)
            {
                return;
            }

            try
            {
                if (HostListener.Pending())
                {
                    //Accept the pending client connection and return a TcpClient object initialized for communication.
                    TcpClient PlayerClient = HostListener.AcceptTcpClient();
                    PlayerClient.NoDelay = true;

                    // Get a stream object for reading and writing
                    NetworkStream PlayerStream = PlayerClient.GetStream();

                    OnlineConnection NewPlayer = new OnlineConnection(PlayerClient, PlayerStream, DicOnlineScripts, WriteBuffer);
                    ListPlayerClient.Add(NewPlayer);
                }
            }
            catch (SocketException)
            {
            }
        }
Esempio n. 2
0
        private void WaitForConnections()
        {
            if (ClientsListener.Pending())
            {
                TcpClient ConnectingClient = ClientsListener.AcceptTcpClient();
                ConnectingClient.NoDelay = true;

                NetworkStream ClientStream = ConnectingClient.GetStream();

                IOnlineConnection NewConnection = new OnlineConnection(ConnectingClient, ClientStream, new Dictionary <string, OnlineScript>(DicOnlineScripts), SharedWriteBuffer);
                OnClientConnected(NewConnection);
            }
        }
Esempio n. 3
0
        private void WaitForConnections()
        {
            if (ClientsListener.Pending())
            {
                TcpClient ConnectingClient = ClientsListener.AcceptTcpClient();
                ConnectingClient.NoDelay = true;

                NetworkStream ClientStream = ConnectingClient.GetStream();

                IOnlineConnection NewConnection = new OnlineConnection(ConnectingClient, ClientStream, DicOnlineScripts);
                OnClientConnected(NewConnection);
            }

            if (MastersListener.Pending())
            {
                TcpClient ConnectingMaster = MastersListener.AcceptTcpClient();
                ConnectingMaster.NoDelay = true;

                NetworkStream MasterStream = ConnectingMaster.GetStream();

                IOnlineConnection NewConnection = new OnlineConnection(ConnectingMaster, MasterStream, DicOnlineScripts);
                OnMasterConnected(NewConnection);
            }
        }