Exemplo n.º 1
0
        private bool AuthenticationRequest()
        {
            _logger.LogDebug("SMS sending AUTHENTICATION_REQUEST start. SendId: {0}", SendId);

            int localPort = Send(ACKPacketFactory.AUTHENTICATION_REQUEST(SendId, Password));

            // If localport == 0 then sending error
            if (localPort == 0)
            {
                return(false);
            }

            // Get requvest
            string ret = Get(localPort);

            // if request error message
            if (ret.StartsWith(string.Format("ERROR {0}", SendId)))
            {
                ErrorMessage = "Authentication error!";
                _logger.LogWarning("SMS sending AUTHENTICATION_REQUEST error. SendId: {0} Return value: {1}", SendId, ret);
                return(false);
            }

            // if not request SEND message
            if (!ret.StartsWith(string.Format("SEND {0}", SendId)))
            {
                ErrorMessage = "Unknow Authentication error!";
                _logger.LogWarning("SMS sending AUTHENTICATION_REQUEST error. SendId: {0} Return value: {1}", SendId, ret);
                return(false);
            }

            _logger.LogDebug("SMS sending AUTHENTICATION_REQUEST sucessfully. SendId: {0}", SendId);

            return(true);
        }