Beispiel #1
0
        protected override void stopGameHandler(UserThread client, CSMessage msg)
        {
            try
            {
                ServerThread cl1 = (ServerThread)client;
                if (cl1.playing())
                {
                    ServerThread cl2 = cl1.CurrentChallenger;
                    if (cl2.playing())
                    {
                        msg.add(MessageType.USER, cl1.ClientUser);
                        cl2.send(msg);
                    }
                    cl2.CurrentChallenger = null;
                    cl1.CurrentChallenger = null;
                    if (view != null && view.isOpened())
                    {
                        view.removeParty(cl1.ClientUser, cl2.ClientUser);
                    }

                    broadcast();
                }
            }
            catch (Exception e)
            {
                log(Severiry.ERROR, "Controller[STOPGAME] - " + e.Message);
            }
        }
Beispiel #2
0
        protected override void deconnectionHandler(UserThread client)
        {
            if (!ps.isStarted())
            {
                return;
            }
            try
            {
                ServerThread cl1 = (ServerThread)client;
                if (cl1.playing())
                {
                    ServerThread cl2 = cl1.CurrentChallenger;
                    CSMessage    msg = new CSMessage(MessageType.STOP_GAME).add(MessageType.USER, cl1.ClientUser);
                    cl2.send(msg);
                    cl2.CurrentChallenger = null;
                    cl1.CurrentChallenger = null;
                    if (view != null && view.isOpened())
                    {
                        view.removeParty(cl1.ClientUser, cl2.ClientUser);
                    }
                }
                else
                {
                    abortRequest(client, client.ClientUser);
                    foreach (CSUser u in client.Froms)
                    {
                        abortRequest(u, client.ClientUser);
                    }
                }

                if (view != null && view.isOpened())
                {
                    view.delete(cl1.ClientUser);
                }
                cl1.stop();
                clients.Remove(cl1);

                broadcast();
            }
            catch (Exception e)
            {
                log(Severiry.ERROR, "Controller[DECONNECTION] - " + e.Message);
            }
        }