コード例 #1
0
ファイル: JudgeClient.cs プロジェクト: uvRen/teamb-simhopp
        public void CommitScore(int judgeIndex, Score score)
        {
            SimhoppMessage.SimhoppStatus status = new SimhoppMessage.SimhoppStatus(Presenter.CurrentRoundIndex, Presenter.CurrentDiverIndex, null);
            SimhoppMessage msg = new SimhoppMessage(judgeIndex, SimhoppMessage.ClientAction.SubmitScore, "", score.Points, status);

            Messages.Enqueue(msg);
        }
コード例 #2
0
ファイル: JudgeClient.cs プロジェクト: uvRen/teamb-simhopp
 public void CommitScore(int judgeIndex, Score score)
 {
     SimhoppMessage.SimhoppStatus status = new SimhoppMessage.SimhoppStatus(Presenter.CurrentRoundIndex, Presenter.CurrentDiverIndex, null);
     SimhoppMessage msg = new SimhoppMessage(judgeIndex, SimhoppMessage.ClientAction.SubmitScore, "", score.Points, status);
     Messages.Enqueue(msg);
 }
コード例 #3
0
ファイル: JudgeServer.cs プロジェクト: uvRen/teamb-simhopp
        private static SimhoppMessage SendContestStatus()
        {
            SimhoppMessage.SimhoppStatus status = new SimhoppMessage.SimhoppStatus(0, 0, _presenter.CurrentEvent);

            return new SimhoppMessage(-2, SimhoppMessage.ClientAction.List, "", 0, status);
        }
コード例 #4
0
ファイル: JudgeServer.cs プロジェクト: uvRen/teamb-simhopp
        private static void SendScoreToConnectedClients(Score score, int roundIndex, int diverIndex, SimhoppMessage.ClientAction action = SimhoppMessage.ClientAction.Ping)
        {
            if (_judgeClients == null)
                return;
            IPEndPoint toDelete = null;
            bool delete = false;
            //Skicka poäng (eller status / request) till anslutna domarklienter
            foreach (IPEndPoint ipep in _judgeClients.Keys)
            {
                try
                {
                    //Skapa statusmeddelande med runda/hopp
                    SimhoppMessage.SimhoppStatus status = new SimhoppMessage.SimhoppStatus(
                        roundIndex,
                        diverIndex,
                        null);

                    SimhoppMessage msg;
                    if (score == null)
                        msg = new SimhoppMessage(-2, action, "", 0, status);
                    else
                        msg = new SimhoppMessage(score.judge.Index((_presenter.Judges)), SimhoppMessage.ClientAction.SubmitScore, "", score.Points, status);

                    LogToServer("Send: " + msg.Serialize());
                    var sendData = Encoding.ASCII.GetBytes(msg.Serialize());
                    _server.Send(sendData, sendData.Length, ipep);
                }
                catch (Exception ex)
                {
                    delete = true;
                    ExceptionHandler.Handle(ex);
                }
            }
            if (delete && toDelete != null)
            {
                try
                {
                    int judgeIndex = _judgeClients[toDelete];
                    _judgeClients.Remove(toDelete);
                    _judges.Remove(judgeIndex);
                    _presenter.LogoutClient(judgeIndex);
                }
                catch (Exception ex)
                {
                    /* Ignore */
                }

            }
        }
コード例 #5
0
ファイル: JudgeServer.cs プロジェクト: uvRen/teamb-simhopp
        private static SimhoppMessage AssignIdToJudge(SimhoppMessage msg, IPEndPoint ipep)
        {
            int index = 0;
            foreach (Judge judge in _presenter.Judges)
            {
                if (judge.Name == msg.Data)
                {
                    Guid guid = Guid.NewGuid();
                    _judges[index] = judge;

                    _judgeClients.Add(ipep, index);

                    SimhoppMessage.SimhoppStatus status = new SimhoppMessage.SimhoppStatus(0, 0, _presenter.CurrentEvent);
                    SimhoppMessage response = new SimhoppMessage(-2, SimhoppMessage.ClientAction.AssignId, guid.ToString(), judge.Index(_presenter.Judges), status);
                    _presenter.AssignJudgeAsClient(index);
                    return response;
                }
                index++;
            }
            return SimhoppMessage.ErrorMessage("Judge not found");
        }