Esempio n. 1
0
 public Chatserver()
 {
     //create our nickname and nickname by connection variables
         nickName = new Hashtable(100);
         nickNameByConnect = new Hashtable(100);
         //create our TCPListener object
         chatServer = new System.Net.Sockets.TcpListener(4296);
         //check to see if the server is running
         //while (true) do the commands
         while (true)
         {
             //start the chat server
             chatServer.Start();
             //check if there are any pending connection requests
             if (chatServer.Pending())
             {
                  //if there are pending requests create a new connection
                 Chat.Sockets.TcpClient chatConnection = chatServer.AcceptTcpClient();
                 //display a message letting the user know they're connected
                 Console.WriteLine("You are now connected");
                 //create a new DoCommunicate Object
                 DoCommunicate comm = new DoCommunicate(chatConnection);
             }
         }
 }
Esempio n. 2
0
        public ChatServer()
        {
            // -Initialise the IPAddress.
            LocalAddress = Dns.GetHostEntry("localhost").AddressList[0];

            //create nickname and nikcnmae by connection varriables
            // - Size of the HASHTABLE here is to prevent large names causing problems.
            nickName          = new Hashtable(100);
            nickNameByConnect = new Hashtable(100);

            //Create TCPListner Object
            // - Nothing I know of uses this port.
            chatServer = new System.Net.Sockets.TcpListener(4296);

            //Check to see if the server is running
            //While (true) do commands

            while (true)
            {
                chatServer.Start();
                if (chatServer.Pending())
                {
                    //If there are pending requests create a new connection
                    Chat.Sockets.TcpClient chatConnection = chatServer.AcceptTcpClient();
                    //Display a warning letting the user know they're connected

                    //TODO: DISPLAY THE NAME OF THE ROOM
                    Console.WriteLine("You are no connected to: ");
                    //Create a new DoCommunicate Object
                    DoCommunicate comm = new DoCommunicate(chatConnection);
                }
            }
        }
Esempio n. 3
0
        public Server()
        {
            nickName          = new Hashtable(100);
            nickNameByConnect = new Hashtable(100);
            chatServer        = new TcpListener(4296);

            while (true)
            {
                chatServer.Start();       //rozpoczecie nasluchwania

                if (chatServer.Pending()) //okresla czy zadania oczekujace polaczenia
                {
                    TcpClient chatConnection = chatServer.AcceptTcpClient();
                    Console.WriteLine("Jesteś połączony :) ");
                    DoCommunicate comm = new DoCommunicate(chatConnection);
                }
            }
        }
Esempio n. 4
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ChatServer"/> class.
    /// </summary>
    /// <param name="port">The port.</param>
    private ChatServer(int port)
    {
        NickNames         = new Hashtable(100);
        NickNameByConnect = new Hashtable(100);
        var chatServer = new TcpListener(IPAddress.Loopback, port);

        while (true)
        {
            chatServer.Start();
            if (!chatServer.Pending())
            {
                continue;
            }

            var chatConnection = chatServer.AcceptTcpClient();
            Console.WriteLine("You are now connected.");
            _ = new DoCommunicate(chatConnection);
        }
    }