Esempio n. 1
0
            //each client must keep track of the network stream between itself and the server
            //the stream reader used by the server to read in client messages
            //the stream writer used by the server to send the client messages
            //an assigned client number
            public Client(Server serverRef, NetworkStream nws, StreamReader sr, StreamWriter sw, int clientNumber)
            {
                this.serverRef = serverRef;
                this.nws = nws;
                this.sr = sr;
                this.sw = sw;
                this.clientNumber = clientNumber;

                //each client has a thread that the server uses to alternate reading in messages from
                thread = new Thread(new ThreadStart(this.Service));
                commandQueue = new Queue<string>();

                switch (clientNumber)
                {
                    case (1):
                        updatePosition(-2.5f, 0);
                        break;
                    case (2):
                        updatePosition(0, 2.5f);
                        break;
                    case (3):
                        updatePosition(2.5f, 0);
                        break;
                    case (4):
                        updatePosition(0, -2.5f);
                        break;
                }
            }
Esempio n. 2
0
            public ServerLoop(Server serverRef)
            {
                this.serverRef = serverRef;

                loopThread = new Thread(new ThreadStart(this.loop));
                collisionThread = new Thread(new ThreadStart(this.CheckCollisions));

                uniClock.Start();
            }
Esempio n. 3
0
 static void Main(string[] args)
 {
     Server server = new Server();
     server.Listen();
     server.listenerThead.Start();
 }