Exemplo n.º 1
0
        private void client_DelimiterDataReceived(object sender, Message packet)
        {
            try
            {
                string[] fields = packet.MessageString.Replace("\r", "").Split(":");
                switch (fields[0])
                {
                case "ADDCLIENT":
                    AddClientDto addClientDto = AddClientDto.Deserialize(fields);
                    OnAddClientDtoReceived(new DtoReceivedEventArgs <AddClientDto>(addClientDto));
                    break;

                case "RMCLIENT":
                    RemoveClientDto removeClientDto = RemoveClientDto.Deserialize(fields);
                    OnRemoveClientDtoReceived(new DtoReceivedEventArgs <RemoveClientDto>(removeClientDto));
                    break;

                case "PD":
                    PilotDataDto pilotDataDto = PilotDataDto.Deserialize(fields);
                    OnPilotDataDtoReceived(new DtoReceivedEventArgs <PilotDataDto>(pilotDataDto));
                    break;

                case "AD":
                    AtcDataDto atcDataDto = AtcDataDto.Deserialize(fields);
                    OnAtcDataDtoReceived(new DtoReceivedEventArgs <AtcDataDto>(atcDataDto));
                    break;

                case "PLAN":
                    FlightPlanDto flightPlanDto = FlightPlanDto.Deserialize(fields);
                    OnFlightPlanDtoReceived(new DtoReceivedEventArgs <FlightPlanDto>(flightPlanDto));
                    break;

                case "PING":
                    PingDto pingDto = PingDto.Deserialize(fields);
                    OnPingDtoReceived(new DtoReceivedEventArgs <PingDto>(pingDto));
                    break;

                case "MC":
                    if (fields[5] == "25")
                    {
                        AtisDataDto atisDataDto = AtisDataDto.Deserialize(fields);
                        OnAtisDataDtoReceived(new DtoReceivedEventArgs <AtisDataDto>(atisDataDto));
                    }

                    break;

                case "NOTIFY":
                    NotifyDto notifyDto = NotifyDto.Deserialize(fields);
                    OnNotifyDtoReceived(new DtoReceivedEventArgs <NotifyDto>(notifyDto));
                    break;

                default:
                    // Not a DTO we need to handle...
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        private void Client_DelimiterDataReceived(object sender, Message packet)
        {
            try
            {
                string[] fields = packet.MessageString.Replace("\r", "").Split(":", 2);
                switch (fields[0])
                {
                case AddClientDto.Packet:
                    AddClientDto addClientDto = AddClientDto.Deserialize(fields[1]);
                    OnAddClientDtoReceived(new DtoReceivedEventArgs <AddClientDto>(addClientDto));
                    break;

                case RemoveClientDto.Packet:
                    RemoveClientDto removeClientDto = RemoveClientDto.Deserialize(fields[1]);
                    OnRemoveClientDtoReceived(new DtoReceivedEventArgs <RemoveClientDto>(removeClientDto));
                    break;

                case PilotDataDto.Packet:
                    PilotDataDto pilotDataDto = PilotDataDto.Deserialize(fields[1]);
                    OnPilotDataDtoReceived(new DtoReceivedEventArgs <PilotDataDto>(pilotDataDto));
                    break;

                case AtcDataDto.Packet:
                    AtcDataDto atcDataDto = AtcDataDto.Deserialize(fields[1]);
                    OnAtcDataDtoReceived(new DtoReceivedEventArgs <AtcDataDto>(atcDataDto));
                    break;

                case FlightPlanDto.Packet:
                    FlightPlanDto flightPlanDto = FlightPlanDto.Deserialize(fields[1]);
                    OnFlightPlanDtoReceived(new DtoReceivedEventArgs <FlightPlanDto>(flightPlanDto));
                    break;

                case PingDto.Packet:
                    PingDto pingDto = PingDto.Deserialize(fields[1]);
                    OnPingDtoReceived(new DtoReceivedEventArgs <PingDto>(pingDto));
                    break;

                case FlightPlanCancelDto.Packet:
                    FlightPlanCancelDto flighplanCancelDto = FlightPlanCancelDto.Deserialize(fields[1]);
                    OnFlightPlanCancelDtoReceived(new DtoReceivedEventArgs <FlightPlanCancelDto>(flighplanCancelDto));
                    break;

                case NotifyDto.Packet:
                    NotifyDto notifyDto = NotifyDto.Deserialize(fields[1]);
                    OnNotifyDtoReceived(new DtoReceivedEventArgs <NotifyDto>(notifyDto));
                    break;

                case "MC":
                    fields = packet.MessageString.Replace("\r", "").Split(":");
                    switch (fields[5])
                    {
                    case "25":
                    {
                        AtisDataDto atisDataDto = AtisDataDto.Deserialize(fields);
                        OnAtisDataDtoReceived(new DtoReceivedEventArgs <AtisDataDto>(atisDataDto));
                        break;
                    }

                    case "5" when fields[1] == "*S":
                    {
                        WallopDto wallopDto = WallopDto.Deserialize(fields);
                        OnWallopDtoReceived(new DtoReceivedEventArgs <WallopDto>(wallopDto));
                        break;
                    }

                    case "5" when fields[1] == "*":