/// <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 void Register(string firstName, string lastName) { // perform the "core" registration logic: // generate an ID // track the registration in our db var id = _idRegistry.AssignId(firstName, lastName); var cmd = _connection.CreateCommand(); cmd.CommandText = "insert into ...."; cmd.ExecuteNonQuery(); // then, notify any other components that need to know when registrations take place. OnRegistration?.Invoke(this, new RegistrationEventArgs { Name = $"{firstName} {lastName}", Id = id }); }
public override void Execute(Client client) { onRegistration?.Invoke(acceptedId, message); }