Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 3.71 KB

responses.md

File metadata and controls

115 lines (83 loc) · 3.71 KB

Responses API

This document describes the API NkSIP makes available to extract information from Responses.

Most functions in the API allows two ways to refer to the responses:

  • From a full response object (nksip:response()). When you use the option callback when using the any request sending function, it is called as {reply, Code, Response, Call}. You can use these API functions inside the function call.
  • From a response handle (nksip:handle()). You can get a response handle from a response object using get_handle/1. You can then use the handle to call most functions in this API.

In this case, the API function must contact with the corresponding call process to get the actual response, so you cannot use this method inside the same call process (like in the callback function). This method is useful to refer to the response from a spawned process, avoiding the need to copy the full object. Please notice that the response object may not exists any longer at the moment that the handle is used. Most functions return error in this case.


Function Description
get_handle/1 Grabs a response's handle
srv_id/1 Gets then Service's internal name
srv_name/1 Gets the Service's user name
code/1 Gets the SIP code of the response
body/1 Gets the body of the response
call_id/1 Gets the Call-ID header of the response
meta/2 Gets specific metadata from the response
metas/2 Gets specific metadata from the response
header/2 Gets the values for a header or headers in a response
wait_491/0 Sleeps a random time between 2.1 and 4 secs

Functions List

get_handle/1

nksip_response:get_handle(nksip:response()|nksip:handle()) ->
    {ok, nksip:handle()} | {error, term()}.

Grabs a response's handle.

srv_id/1

nksip_response:srv_id(nksip:response()|nksip:handle()) -> 
    {ok, nksip:srv_id()} | {error, term()}.

Gets then Service's internal name.

srv_name/1

nksip_response:srv_name(nksip:response()|nksip:handle()) -> 
    {ok, nksip:srv_name()}  | {error, term()}.

Gets the Service's user name

code/1

nksip_response:code(nksip:response()|nksip:handle()) ->
    {ok, nksip:sip_code()} | {error, term()}.

Gets the SIP code of the response.

body/1

nksip_response:body(nksip:response()|nksip:handle()) ->
    {ok, nksip:body()} | {error, term()}.

Gets the body of the response.

call_id/1

nksip_response:call_id(nksip:response()|nksip:handle()) ->
    {ok, nksip:call_id()} | {error, term()}.

Gets the Call-ID header of the response.

meta/2

nksip_response:meta(Meta::nksip_sipmsg:field(), nksip:response()|nksip:handle()) ->
    {ok, term()} | {error, term()}.

Gets specific metadata from the response.

See Metadata Fields for a description of available fields.

metas/2

nksip_response:meta(Meta::[nksip_sipmsg:field()], nksip:response()|nksip:handle()) ->
    {ok, [{nksip_sipmsg:field(), term()}]} | {error, term()}.

Gets specific metadata from the response.

See Metadata Fields for a description of available fields.

header/2

nksip_response:header(Name::string()|binary(), nksip:response()|nksip:handle()) -> 
    {ok, [binary()]} | {error, term()}.

Gets all the values for a header.

NkSIP uses only lowercase for header names.

wait_491/0

nksip_response:wait_491() -> 
    ok.

Sleeps a random time between 2.1 and 4 secs. It should be called after receiving a 491 response and before trying the response again.