Beispiel #1
0
        public async void Run()
        {
            IsRunning = true;
            await Task.Run(async() =>
            {
                while (IsRunning)
                {
                    try
                    {
                        string response = await conn.WaitForResponse();
                        Tuple <string[], PacketType> packet = packetHandler.HandlePacket(response);

                        switch (packet.Item2)
                        {
                        case PacketType.Status:
                            StatusReceived?.Invoke(new StatusArgs(packet.Item1[1]));
                            break;

                        case PacketType.DoctorDisconnect:
                            DoctorDisconnectReceived?.Invoke(new EventArgs());
                            break;

                        case PacketType.Resistance:
                            ResistanceReceived?.Invoke(new ResistanceArgs(packet.Item1[1]));
                            break;

                        case PacketType.Broadcast:
                            BroadcastReceived?.Invoke(new BroadcastArgs(packet.Item1[1]));
                            break;

                        case PacketType.Message:
                            MessageReceived?.Invoke(new MessageArgs(packet.Item1[1]));
                            break;

                        case PacketType.StopVR:
                            StopReceived?.Invoke(new EventArgs());
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        IsRunning = false;
                    }
                }
            });
        }
Beispiel #2
0
 protected virtual void OnStopReceived(AMCPEventArgs e)
 {
     StopReceived?.Invoke(this, e);
 }