Пример #1
0
        /// <summary>
        /// IEASProtocol.IEASSenderType 을 로컬 데이터 타입 SenderTypes 형으로 변환.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private SenderTypes ConvertToLocalSenderType(IEASSenderType type)
        {
            SenderTypes senderType = SenderTypes.IAGW;

            switch (type)
            {
            case IEASSenderType.SAS:
            {
                senderType = SenderTypes.SAS;
            }
            break;

            case IEASSenderType.SWI:
            {
                senderType = SenderTypes.SWI;
            }
            break;

            case IEASSenderType.IAGW:
            default:
            {
                senderType = SenderTypes.IAGW;
            }
            break;
            }

            return(senderType);
        }
Пример #2
0
        public IMessageSender GetSender(SenderTypes type)
        {
            switch (type)
            {
            case SenderTypes.SMS:
                return(new SMSMessageSender(_config));

            default:
                throw new NotSupportedException();
            }
        }
Пример #3
0
        public async Task <bool> SendAsync(string subject, string message, SenderTypes senderType, string receiverEmail)
        {
            EmailSender emailConfigurationSender = _emailConfiguration.Senders.FirstOrDefault(x => x.Type.Equals(senderType));

            if (emailConfigurationSender == null)
            {
                return(false);
            }

            using (SmtpClient client = new MailKit.Net.Smtp.SmtpClient())
            {
                await client.ConnectAsync(_emailConfiguration.Host, _emailConfiguration.Port);

                await client.AuthenticateAsync(emailConfigurationSender.Username, emailConfigurationSender.Password);

                MimeMessage mailMessage = new MimeMessage
                {
                    Body = new TextPart(MimeKit.Text.TextFormat.Html)
                    {
                        Text = message
                    },
                    From =
                    {
                        new MailboxAddress(_emailConfiguration.DisplayName, emailConfigurationSender.Username)
                    },
                    To =
                    {
                        new MailboxAddress(receiverEmail)
                    },
                    Subject = subject
                };

                await client.SendAsync(mailMessage);

                await client.DisconnectAsync(true);
            }

            return(true);
        }
Пример #4
0
 public static bool ValidateSender(this GlobalEventListener listener, Event evnt, SenderTypes senderType = SenderTypes.Any)
 {
     return((CoopPeerStarter.Dedicated && evnt.RaisedBy == BoltNetwork.server) || evnt.RaisedBy == null || !(MpPlayerList.GetEntityFromBoltConnexion(evnt.RaisedBy) == null));
 }
Пример #5
0
 public static bool ValidateSender(this GlobalEventListener listener, Event evnt, SenderTypes senderType = SenderTypes.Any)
 {
     return(true);
 }
Пример #6
0
        /// <summary>
        /// 큐에 저장된 패킷 데이터를 프레임 단위로 파싱.
        /// </summary>
        private int DistributeKCAPCommandData(KCAPCmdValue command, IEASProtocolBase baseData)
        {
            try
            {
                System.Console.WriteLine("[CommunicationManager] KCAP 프레임 데이터 분배 - command(" + command + ")");
                switch (command)
                {
                case KCAPCmdValue.OrderResponse:
                {
                    IEASPrtCmd2 protoCmd2 = baseData as IEASPrtCmd2;
                    if (this.NotifyCAPReceived != null)
                    {
                        CAP             capMsg     = new CAP(protoCmd2.CAPMessage);
                        SenderTypes     senderType = ConvertToLocalSenderType(protoCmd2.SenderType);
                        ReceivedCAPInfo capInfo    = new ReceivedCAPInfo(senderType, capMsg);
                        this.NotifyCAPReceived(this, new CapEventArgs(capInfo));
                    }
                }
                break;

                case KCAPCmdValue.AuthResult:
                {
                    IEASPrtCmd4 protoCmd4 = baseData as IEASPrtCmd4;
                    if (this.NotifyIAGWConnectionState != null)
                    {
                        if (protoCmd4.SenderType == IEASSenderType.IAGW)
                        {
                            bool authResult = (protoCmd4.AuthentiResult == 0x01) ? true : false;
                            IAGWConnectionEventArgs copy = new IAGWConnectionEventArgs();
                            lock (this.currentIAGWConnectionState)
                            {
                                this.currentIAGWConnectionState.IsAuthenticated = authResult;
                                copy.DeepCopyFrom(this.currentIAGWConnectionState);
                            }
                            this.NotifyIAGWConnectionState(this, copy);
                        }
                        else
                        {
                            // 메시지 유효성 오류: 무시
                        }
                    }
                }
                break;

                case KCAPCmdValue.Order:
                {
                    IEASPrtCmd1 protoCmd1 = baseData as IEASPrtCmd1;
                    if (this.NotifyCAPReceived != null)
                    {
                        CAP             capMsg     = new CAP(protoCmd1.CAPMessage);
                        SenderTypes     senderType = ConvertToLocalSenderType(protoCmd1.SenderType);
                        ReceivedCAPInfo capInfo    = new ReceivedCAPInfo(senderType, capMsg);
                        this.NotifyCAPReceived(this, new CapEventArgs(capInfo));
                    }
                }
                break;

                case KCAPCmdValue.Polling:
                default:
                {
                    // do nothing
                }
                break;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] DistributeKCAPCommandData( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] DistributeKCAPCommandData( Exception=[" + ex.ToString() + "] )");

                return(-99);
            }

            return(0);
        }
Пример #7
0
 public ReceivedCAPInfo(SenderTypes senderType, CAP msg)
 {
     this.msg           = msg;
     this.msgSenderType = senderType;
 }
Пример #8
0
 public DataItem(long payload, SenderTypes sender, DataTransaction transaction, TransactionValidation nodeValidation, Connection connection) : base(payload, sender, connection)
 {
     Transaction    = transaction;
     NodeValidation = nodeValidation;
 }
Пример #9
0
 public ServiceItem(long payload, SenderTypes sender, ServiceTransaction transaction, Connection connection) : base(payload, sender, connection)
 {
     Transaction = transaction;
 }
Пример #10
0
 public Item(long payload, SenderTypes sender, Connection connection)
 {
     Payload    = payload;
     Sender     = sender;
     Connection = connection;
 }