<commit_before># UAC Auto Registration Plugin

* [Name](#name)
* [Description](#description)
* [Dependant Plugins](#dependant-plugins)
* [Configuration Values](#configuration-values)
* [API Functions](#api-functions)
* [Callback Functions](#callback-functions)
* [Examples](#examples)


## Name
### `nksip_uac_auto_register`


## Description

This plugin allows a SipApp to program a serie of automatic registrations (sending REGISTER request) to a remote registrar, or automatic pings (sending OPTIONS requests) to any other SIP entity.


## Dependant Plugins

None


## Configuration Values

### SipApp configuration values

Option|Default|Description
---|---|---
nksip_uac_auto_register_timer|5 (secs)|Interval to check for new expired timers


## API functions

### start_register/4 

```erlang
start_register(App::nksip:app_name()|nksip:app_id(), Id::term(), Uri::nksip:user_uri(), 
               Opts::nksip:optslist()) -> 
    {ok, boolean()} | {error, term()}.
```

Programs the SipApp to start a serie of automatic registrations to the registrar at `Uri`. `Id` indentifies this request to be be able to stop it later. Use [get_registers/1](#get_registers1) or the  callback function [sip_uac_auto_register_update/3](#sip_uac_auto_register_update3) to know about the registration status.

Opts are passed to the REGISTER sending functions. You can use the `expires` option to change the default re-register time from the default of 300 secs.


### stop_register/2

```erlang
stop_register(App::nksip:app_name()|nksip:app_id(), Id::term()) -> 
    ok | not_found.
```

Stops a previously started registration serie.


### get_registers/1

```erlang
get_registers(App::nksip:app_name()|nksip:app_id()) -> 
    [{Id::term(), OK::boolean(), Time::non_neg_integer()}].
```
Get current registration status, including if last registration was successful and time remaining to next one.
 

### start_ping/4

```erlang
start_ping(App::nksip:app_name()|nksip:app_id(), Id::term(), Uri::nksip:user_uri(), 
		   Opts::nksip:optslist()) -> 
    {ok, boolean()} | {error, term()}.


Programs the SipApp to start a serie of _pings_ (OPTION requests) to the SIP element at `Uri`. `Id` indentifies this request to be able to stop it later. Use [get_pings1](#get_pings1) or the callback function [sip_uac_auto_ping_update/3](#sip_uac_auto_ping_update3) to know about the ping status.

You can use the `expires` option to change the default re-options time from the default of 300 secs.



### stop_ping/2

```erlang
stop_ping(App::nksip:app_name()|nksip:app_id(), Id::term()) ->
    ok | not_found.

Stops a previously started ping serie.


### get_pings/1

```erlang
get_pings(App::nksip:app_name()|nksip:app_id()) -> 
    [{Id::term(), OK::boolean(), Time::non_neg_integer()}].
```

Get current ping status, including if last ping was successful and time remaining to next one.
 


## Callback functions

You can implement any of these callback functions in your SipApp callback module.



### sip_uac_auto_register_updated_register/3

```erlang
sip_uac_auto_register_updated_register(Id::term(), OK::boolean(), 
                                             AppId::nksip:app_id()) ->
    ok.
```
<commit_msg>Update auto_register.md<commit_after># UAC Auto Registration Plugin

* [Name](#name)
* [Description](#description)
* [Dependant Plugins](#dependant-plugins)
* [Configuration Values](#configuration-values)
* [API Functions](#api-functions)
* [Callback Functions](#callback-functions)
* [Examples](#examples)


## Name
### `nksip_uac_auto_register`


## Description

This plugin allows a SipApp to program a serie of automatic registrations (sending REGISTER request) to a remote registrar, or automatic pings (sending OPTIONS requests) to any other SIP entity.


## Dependant Plugins

None


## Configuration Values

### SipApp configuration values

Option|Default|Description
---|---|---
nksip_uac_auto_register_timer|5 (secs)|Interval to check for new expired timers


## API functions

### start_register/4 

```erlang
start_register(App::nksip:app_name()|nksip:app_id(), Id::term(), Uri::nksip:user_uri(), 
               Opts::nksip:optslist()) -> 
    {ok, boolean()} | {error, term()}.
```

Programs the SipApp to start a serie of automatic registrations to the registrar at `Uri`. `Id` indentifies this request to be be able to stop it later. Use [get_registers/1](#get_registers1) or the  callback function [sip_uac_auto_register_updated_register/3](#sip_uac_auto_register_updated_register3) to know about the registration status.

Opts are passed to the REGISTER sending functions. You can use the `expires` option to change the default re-register time from the default of 300 secs.


### stop_register/2

```erlang
stop_register(App::nksip:app_name()|nksip:app_id(), Id::term()) -> 
    ok | not_found.
```

Stops a previously started registration serie.


### get_registers/1

```erlang
get_registers(App::nksip:app_name()|nksip:app_id()) -> 
    [{Id::term(), OK::boolean(), Time::non_neg_integer()}].
```
Get current registration status, including if last registration was successful and time remaining to next one.
 

### start_ping/4

```erlang
start_ping(App::nksip:app_name()|nksip:app_id(), Id::term(), Uri::nksip:user_uri(), 
		   Opts::nksip:optslist()) -> 
    {ok, boolean()} | {error, term()}.
```

Programs the SipApp to start a serie of _pings_ (OPTION requests) to the SIP element at `Uri`. `Id` indentifies this request to be able to stop it later. Use [get_pings1](#get_pings1) or the callback function [sip_uac_auto_register_updated_ping/3](#sip_uac_auto_register_updated_ping3) to know about the ping status.

You can use the `expires` option to change the default re-options time from the default of 300 secs.



### stop_ping/2

```erlang
stop_ping(App::nksip:app_name()|nksip:app_id(), Id::term()) ->
    ok | not_found.

Stops a previously started ping serie.
```

### get_pings/1

```erlang
get_pings(App::nksip:app_name()|nksip:app_id()) -> 
    [{Id::term(), OK::boolean(), Time::non_neg_integer()}].
```

Get current ping status, including if last ping was successful and time remaining to next one.
 


## Callback functions

You can implement any of these callback functions in your SipApp callback module.



### sip_uac_auto_register_updated_register/3

```erlang
sip_uac_auto_register_updated_register(Id::term(), OK::boolean(), 
                                             AppId::nksip:app_id()) ->
    ok.
```

{'fraction_non_alphanumeric': 0.13115515639516878, 'fraction_numerical': 0.006813254877671105, 'mean_word_length': 4.866485013623978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5296767', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2047, 'n_words': 605}