Example #1
0
 private void requestPatient_Click(object sender, EventArgs e)
 {
     Packet request = new Packet();
     request.Flag = Packet.PacketFlag.PACKETFLAG_REQUEST_SPECIFIC_WINGATE;
     RequestSpecificWingatePatient specify = new RequestSpecificWingatePatient();
     specify.name = patientNameBox.Text;
     request.Data = specify;
     connect.sendPacket(request);
 }
Example #2
0
 public void ServerResponse(Packet packet)
 {
     Thread t = new Thread(() =>
     {
         Application.Run(new WingateFormResults(packet));
     });
     t.SetApartmentState(ApartmentState.STA);
     t.IsBackground = true;
     t.Start();
 }
Example #3
0
        public WingateFormResults(Packet packet)
        {
            InitializeComponent();

            List<WingateResult> data = packet.Data as List<WingateResult>;
            if (data != null)
            {
                results = data;
                foreach (WingateResult result in results)
                {
                    listBox1.Items.Add(result.Patient +" - "+ results.IndexOf(result));
                }
            }
        }
Example #4
0
        ///<summary>
        ///Handles datapackets received by clients.
        ///</summary>
        public static void getPacket(ServerControl serverControl, Client client, Packet pack)
        {
            switch (pack.Flag)
            {
                case Packet.PacketFlag.PACKETFLAG_VALUES:
                    serverControl.writeToModel(client, (Value)pack.Data);
                    serverControl.ForwardedValuePacket(client, pack);
                    break;

                case Packet.PacketFlag.PACKETFLAG_CHAT:
                    serverControl.forwardMessage(pack, client);
                    break;

                case Packet.PacketFlag.PACKETFLAG_BIKECONTROL:
                    serverControl.forwardBikeCommand(pack);
                    break;

                case Packet.PacketFlag.PACKETFLAG_REQUEST_HANDSHAKE:
                    setUsernamePassword(client, pack);
                    serverControl.handshakeResponse(client, (Handshake)pack.Data);
                    break;

                case Packet.PacketFlag.PACKETFLAG_REQUEST_VALUES:
                    client.sendHandler(serverControl.requestSpecifiedClientData((RequestValue)pack.Data));
                    break;
                case Packet.PacketFlag.PACKETFLAG_REQUEST_USERLIST:
                    client.sendHandler(serverControl.getOnlineClientListPacket());
                    break;
                case Packet.PacketFlag.PACKETFLAG_WINGATE_RESULT:
                    serverControl.WingateResult(pack);
                    break;
                case Packet.PacketFlag.PACKETFLAG_REQUEST_ALL_WINGATE:
                    serverControl.ResponseWingate(client);
                    break;
                case Packet.PacketFlag.PACKETFLAG_REQUEST_SPECIFIC_WINGATE:
                    serverControl.ResponseWingate(client, pack);
                    break;
                default:
                    Console.WriteLine("Error: unhandled Packet received - {0}", pack.Flag);
                    break;
            }
        }
Example #5
0
 public Packet packIt()
 {
     packet = new Packet();
     packet.Flag = Packet.PacketFlag.PACKETFLAG_WINGATE_RESULT;
     WingateResult result = new WingateResult();
     result.AnaerobicCapacity = anaerobicCapacity;
     result.AnaerobicFatique = anaerobicFatique;
     result.LowestPower = lowestPower;
     result.Patient = patientName;
     result.PeakPower = peakPower;
     result.RelativePeakPower = relativePeakPower;
     result.Values = valueList;
     packet.Data = result;
     networkClient.routeToServer(packet);
     return packet;
 }
Example #6
0
 ///<summary>
 ///Forwards client-credentials.
 ///</summary>
 public static void setUsernamePassword(Client client, Packet pack)
 {
     client.setUsernamePassword(((Handshake)pack.Data).Username, ((Handshake)pack.Data).Password);
     client.isDoctor = ((Handshake) pack.Data).ClientFlag == Kettler_X7_Lib.Objects.Client.ClientFlag.CLIENTFLAG_DOCTORAPP;
 }
Example #7
0
 internal void requestData(string user, DateTime start, DateTime end)
 {
     Kettler_X7_Lib.Objects.Packet Pack = new Kettler_X7_Lib.Objects.Packet();
     Pack.Flag = Kettler_X7_Lib.Objects.Packet.PacketFlag.PACKETFLAG_REQUEST_VALUES;
     Pack.Data = new Kettler_X7_Lib.Objects.RequestValue()
     {
         ClientName = user,
         Start = start,
         End = end
     };
     sendPacket(Pack);
 }
Example #8
0
 public void sendMessage(string message, string reciever)
 {
     Kettler_X7_Lib.Objects.Packet Pack = new Kettler_X7_Lib.Objects.Packet();
     Pack.Flag = Kettler_X7_Lib.Objects.Packet.PacketFlag.PACKETFLAG_CHAT;
     Pack.Data = new Kettler_X7_Lib.Objects.ChatMessage()
     {
         Receiver = reciever,
         Sender = "Jim",
         Message = message
     };
     sendPacket(Pack);
 }
Example #9
0
 public void sendCommand(string command, string client)
 {
     Kettler_X7_Lib.Objects.Packet Pack = new Kettler_X7_Lib.Objects.Packet();
     Pack.Flag = Kettler_X7_Lib.Objects.Packet.PacketFlag.PACKETFLAG_BIKECONTROL;
     Pack.Data = new Kettler_X7_Lib.Objects.BikeControl()
     {
        Command = command ,
        Receiver = client
     };
     sendPacket(Pack);
 }
Example #10
0
 public void requestUsers()
 {
     Kettler_X7_Lib.Objects.Packet Pack = new Kettler_X7_Lib.Objects.Packet();
     Pack.Flag = Kettler_X7_Lib.Objects.Packet.PacketFlag.PACKETFLAG_REQUEST_USERLIST;
     sendPacket(Pack);
 }
Example #11
0
        public void Login(string login, string password, string ip)
        {
            Kettler_X7_Lib.Objects.Packet Pack = new Kettler_X7_Lib.Objects.Packet();
            Pack.Flag = Kettler_X7_Lib.Objects.Packet.PacketFlag.PACKETFLAG_REQUEST_HANDSHAKE;
            Pack.Data = new Kettler_X7_Lib.Objects.Handshake()
            {
                ClientFlag = Kettler_X7_Lib.Objects.Client.ClientFlag.CLIENTFLAG_DOCTORAPP,
                Username = login,
                Password = password

            };
             tcpClient = new TcpClient(ip, 31337);
             this.ip = ip;
             stream = new SslStream(tcpClient.GetStream(), false, new System.Net.Security.RemoteCertificateValidationCallback(checkCert), null);
             try
             {
                 stream.AuthenticateAsClient(ip);
             }
             catch
             {
             }
             sendPacket(Pack);
             logged = true;
             Thread Comm = new Thread(new ParameterizedThreadStart(HandleCommunication));
             Comm.Start(tcpClient);
             lost = 0;
             this.login = login;
             this.pass = password;
            //temp code for testing without server
            //Program.form2.denied(2);
            //Program.form2.Close();
            //clientStream.Write(), 0, );
        }
Example #12
0
 public void WingateResponseReceived(Packet packet)
 {
     wingateForm.ServerResponse(packet);
 }
Example #13
0
 private void requestAll_Click(object sender, EventArgs e)
 {
     Packet request = new Packet();
     request.Flag = Packet.PacketFlag.PACKETFLAG_REQUEST_ALL_WINGATE;
     connect.sendPacket(request);
 }