private static void ParseCommand(NetCommand command)
        {
            switch (command.Type)
            {
            case NetCommand.CommandType.VALUESET:
                ParseValueSet(command);
                break;

            case NetCommand.CommandType.CHAT:
                ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, true);
                Chat.Add(chat);
                Client.chat.Invoke(Client.chat.passChatMessage, new Object[] { chat });
                break;

            case NetCommand.CommandType.RESPONSE:
                Console.WriteLine(command.Response.ToString());
                break;

            case NetCommand.CommandType.SESSION:
                Session = command.Session;
                break;

            case NetCommand.CommandType.ERROR:
                Console.WriteLine("An error occured, ignoring");
                break;

            case NetCommand.CommandType.SESSIONDATA:
                if (SessionsBeingSent)
                {
                    oldSessionsData.Add(new Tuple <string, double, int>(command.DisplayName, command.Timestamp, command.Session));
                    SessionsSent++;
                    //if (SessionsSent >= SessionsLength)
                    //    SessionsBeingSent = false;
                }
                break;

            case NetCommand.CommandType.DATA:
                lock (Metingen)
                {
                    Metingen.Add(command.Meting);
                }
                //window.Invoke(window.updateMetingen, new Object[] { command.Meting });
                break;

            default:
                throw new FormatException("Error in Netcommand: Received command not recognized");
            }
        }
        public void HandleCommand(NetCommand command)
        {
            switch (command.Type)
            {
            case NetCommand.CommandType.DATA:
                lock (Metingen)
                {
                    Metingen.Add(command.Meting);
                }
                window.Invoke(window.updateMetingen, new Object[] { command.Meting });
                break;

            case NetCommand.CommandType.CHAT:
                ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor);
                Chat.Add(chat);
                window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { chat });
                break;
            }
        }
        public static Meting SaveMeting(string meting)
        {
            Meting m = null;

            try
            {
                m = Meting.Parse(meting);
            }
            catch (Exception e)
            {
                return(new Meting(0, 0, 0, 0, 0, 0, 0, 0, 0));
            }


            Metingen.Add(m);
            if (Doctor.Connected)
            {
                NetHelper.SendNetCommand(Doctor, new NetCommand(m, Session));
            }

            return(m);
        }
示例#4
0
        public void HandleCommand(NetCommand command)
        {
            switch (command.Type)
            {
            case NetCommand.CommandType.DATA:
                if (command != null && command.Meting != null)
                {
                    lock (Metingen)
                    {
                        Metingen.Add(command.Meting);
                    }
                    window.Invoke(window.updateMetingen, new Object[] { command.Meting });
                }
                break;

            case NetCommand.CommandType.CHAT:
                ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor);
                Chat.Add(chat);
                window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { chat });
                break;

            case NetCommand.CommandType.UITLEG:
                window.steps.UitlegText.Invoke((MethodInvoker)(() => window.steps.UitlegText.Text = command.UitlegText));
                break;

            case NetCommand.CommandType.PERSONDATA:
                window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { new ChatMessage("Test", "DATA Gewicht=" + command.Gewicht + " Geslacht=" + command.Geslacht + " Leeftijd=" + command.Leeftijd + " Lengte=" + command.Lengte + ".", false) });
                Console.WriteLine("Not fully implemented");
                //NOG DOEN
                break;

            case NetCommand.CommandType.TESTRESULT:
                window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { new ChatMessage("Test", "DATA Vo2Max=" + command.VO2Max + " MET=" + command.MET + " PopulationAvg=" + command.PopulationAvg + " Zscore=" + command.ZScore + " Rating=" + command.Rating + ".", false) });
                Console.WriteLine("Not fully implemented");
                //NOG DOEN
                break;
            }
        }