Files Loading and Callbacks Order
This section describes the steps that take place when different actions are executed or an event is triggered.
System Events
OverSIP starts
When OverSIP is started it performs the following steps:
- oversip.confand- proxies.confare loaded and configuration parameters validated.
- server.rbis loaded.
- OverSIP::SystemEvents.on_initializemethod is called.- Usually the user places here code for setting and initializing 3rd party modules (i.e. database connection settings).
 
- All the callbacks set by 3rd party modules via OverSIP::SystemCallbacks.on_startedare executed.- Typically the modules use the settings placed by the user into OverSIP::SystemEvents.on_initialize(for example a database module would here perform the database connection).
 
- Typically the modules use the settings placed by the user into 
- OverSIP::SystemEvents.on_startedmethod is called.- Modules are already set so the user can here make usage of them (i.e. for retrieving initial data from a database).
 
- The event loop starts.
OverSIP terminates
When OverSIP is stopped it performs the following steps:
- OverSIP::SystemEvents.on_terminatedmethod is called.- The user can here run some code before exiting.
- NOTE: This step does not take place if OverSIP failed to start.
 
- All the callbacks set by 3rd party modules via OverSIP::SystemCallbacks.on_terminatedare executed in reverse order.- Here 3rd party modules can free resources if needed or make a final action.
- NOTE: This step does not take place if OverSIP failed to start.
 
OverSIP is reloaded
When OverSIP is reloaded (via a HUP signal or /etc/init.d/oversip reload) it performs the following steps:
- proxies.confis reloaded and configuration parameters validated.
- server.rbis reloaded.
- All the callbacks set by 3rd party modules via OverSIP::SystemCallbacks.on_reloadare executed.- Here the modules can perform some required action.
 
OverSIP is user-reloaded
When OverSIP is user-reloaded (via a USR1 signal or /etc/init.d/oversip user-reload) it performs the following steps:
- OverSIP::SystemEvents.on_user_reloadmethod is called.- Here the user can place custom code (i.e. for reloading an Arrayvariable with data retrieved from the database).
 
- Here the user can place custom code (i.e. for reloading an 
SIP Events
A SIP client initiates a TLS connection with OverSIP
When a SIP client initiates a TLS handshake OverSIP performs the following steps:
- OverSIP::SipEvents.on_client_tls_handshakemethod is called.
OverSIP initiates a TLS connection with a SIP server
When OverSIP attempts to open a SIP TLS connection with a server it performs the following steps:
- OverSIP::SipEvents.on_server_tls_handshakemethod is called.
A SIP request is received
When OverSIP receives a SIP request it performs the following steps:
- OverSIP::SipEvents.sip_on_requestmethod is called.
WebSocket Events
A WebSocket client initiates a TLS connection with OverSIP
When a WebSocket client initiates a TLS handshake (thus WSS protocol) OverSIP performs the following steps:
- OverSIP::WebSocketEvents.on_client_tls_handshakemethod is called.
A WebSocket handshake request is received
When OverSIP receives a WebSocket handshake request (HTTP GET method) it performs the following steps:
- OverSIP::WebSocketEvents.on_connectionmethod is called.
A WebSocket established connection is closed
When a successfully established WebSocket connection is closed (by the client or by OverSIP) OverSIP performs the following steps:
- OverSIP::WebSocketEvents.on_disconnectionmethod is called.