Beispiel #1
0
        /// <summary>
        /// Manage incoming message from the given client's socket.
        /// </summary>
        /// <param name="tcpclient"></param>
        private void incomingClient(TcpClient tcpclient)
        {
            ServerThread client = new ServerThread(tcpclient);

            client.messageHandler      = new UserThread.newMessageHandler(handleMessage);
            client.loginHandler        = new UserThread.newLoginHandler(loginHandler);
            client.challengerHandler   = new UserThread.newChallengerHandler(challengerHandler);
            client.deconnectionHandler = new UserThread.newDeconnectionHandler(deconnectionHandler);
            client.endGameHandler      = new UserThread.newEndGameHandler(endGameHandler);
            client.stopGameHandler     = new UserThread.newStopGameHandler(stopGameHandler);

            CSMessage tosend = new CSMessage(MessageType.CONNECTION);

            tosend.add(MessageType.USER, client.ClientUser);
            client.send(tosend);
            client.start();
            clients.Add(client);
            broadcast();

            if (view != null && view.isOpened())
            {
                view.addUser(client.ClientUser);
            }
        }