Example #1
0
        /// <summary>
        /// Extract registration packet
        /// </summary>
        /// <param name="data"></param>
        private void Registration(string data, string host, int port)
        {
            _logger.LogDebug("Start Registration processing");

            GoIpRegistrationPacket packet = new GoIpRegistrationPacket(data);

            // if auth error
            if (packet.authid != _options.AuthId || packet.password != _options.AuthPassword)
            {
                // TODO: log?
                _logger.LogInformation("Received registration data authentication error. Data: {0}", data);
                Send(ACKPacketFactory.ACK_MESSAGE(packet.req, 400), host, port);
                OnRegistration?.Invoke(this, new GoIpRegisterEventArgs("Authentication error!", packet, host, port, 400));
                return;
            }

            packet.password = "";  // Delete password for security reasons

            if (string.IsNullOrEmpty(packet.imei))
            {
                _logger.LogInformation("Received SMS data without IMEI. packet id: {0}", packet.authid);
                Send(ACKPacketFactory.ACK_MESSAGE(packet.req, 400), host, port);
                OnRegistration?.Invoke(this, new GoIpRegisterEventArgs("No IMEI! (No SIM?)", packet, host, port, 400));
                return;
            }

            _logger.LogInformation("Received registration OK. Packet id: {0} IMEI: {1}", packet.authid, packet.imei);
            Send(ACKPacketFactory.ACK_MESSAGE(packet.req, 200), host, port);
            OnRegistration?.Invoke(this, new GoIpRegisterEventArgs("OK", packet, host, port, 400));
        }
 public GoIpRegisterEventArgs(string message, GoIpRegistrationPacket packet, string host, int port, int status)
 {
     Packet  = packet;
     Host    = host;
     Port    = port;
     Status  = status;
     Message = message;
 }