The package implements a communication endpoint for SIP. This is usually a phone, but can also be a stateful proxy (because it retransmits packets itself).

It provides methods to send arbitrary requests but also for sending special requests like INVITE or REGISTER. Together with Net::SIP::Endpoint::Context it implements the behavior of the endpoint.

For incoming requests the endpoint usually communicates with the upper layer, the application, which is the interface to the user (e.g. let it ring for incoming calls, create response for call accepted if user picks up phone on incoming call etc).

Creates a new endpoint and sets it as the receiver for incoming packets at the Net::SIP::Dispatcher DISPATCHER. The endpoint will use DISPATCHER for outgoing packets and will receive incoming packets from it.

Sets APP as the upper layer, e.g. the layer between the user and the endpoint object $self. APP is either an object which has a method receive or a callback usable by invoke_callback in Net::SIP::Util.

In this case APP should ring the user and while ringing send 180 Ringing responses back to the peer, using ENDPOINT->new_response. After some time it should send a final response (like 200 Ok if the user accepted the call).

This informs APP, that the call is closed. No need for the APP to send a response itself, this was already handled by the endpoint (because there is no choice of responses, it can hardly not accept a BYE).

Method is the uppercase name of the method for which a request should be generated. It can also be already a Net::SIP::Request object in which case no new request object will be generated, but the provided delivered.

CTX is either an existing Net::SIP::Endpoint::Context object or a hash reference which will be used to construct one. It contains information about from and to etc. See constructor in Net::SIP::Endpoint::Context for details. In case of a hash reference auth and callid from ARGS will be used for the newly constructed context.

If it is an existing CTX it has to be one which is already managed by this endpoint (e.g. one returned by this method), the endpoint will only manage CTX which it created itself so that a context cannot be shared between multiple endpoints.

CALLBACK is a callback usable by invoke_callback in Net::SIP::Util. If defined it will be set up as the new default callback for the context.

BODY is a string or an object for the SIP body accepted by the constructor of Net::SIP::Request. See there.

If a response object is given as resp40x in ARGS it will be used to authorize the newly created request.

Anything else in %ARGS will be used to construct the SIP header. See constructor in Net::SIP::Request.

Handles incoming response packets. Tries to find an active call based on the Call-Id header in the packet. If none was found it will drop the packet, otherwise call handle_response on the call context object (Net::SIP::Endpoint::Context).

If there is already a call context for this Call-Id in the request it will use it, otherwise it will create a Net::SIP::Endpoint::Context object based on the information in the request (from, to, contact,... ).

Delivers Net::SIP::Response packet RESPONSE through the endpoints dispatcher to ADDR ("ip:port") using Net::SIP::Leg LEG. LEG and ADDR are usually the leg and the senders address where the associated request came in.

CTX is the context from the call, where the associated request came in.

If the response is a 2xx response to a INVITE and no contact header is given as required from the RFC it will add one based on the CTX.