Parrot.Sip.Method (Parrot Platform v0.0.1-alpha.2)
Module for working with SIP methods as defined in RFC 3261 and extensions.
SIP methods indicate the purpose of a SIP request. This module provides functions for handling standard SIP methods and custom method names.
References:
- RFC 3261 Section 7.1: SIP Methods
- RFC 3261 Section 8.1: UAC Behavior
- RFC 3261 Section 20.1: Method Parameter
- RFC 6665: SIP-Specific Event Notification (SUBSCRIBE, NOTIFY)
- RFC 3515: The SIP Refer Method
- RFC 3311: The SIP UPDATE Method
- RFC 3903: SIP Extension for Event State Publication (PUBLISH)
- RFC 3428: SIP Extension for Instant Messaging (MESSAGE)
- RFC 4028: Session Timers in SIP (INFO)
Summary
Functions
Checks if a method is allowed to have a body.
Checks if a method can be canceled.
Checks if a method establishes a dialog.
Checks if a method is a standard SIP method.
Converts a string to a method atom. For standard methods, returns a lowercase atom. For custom methods, returns an uppercase atom.
Same as parse/1
but raises an error for invalid methods.
Checks if a method requires Contact header.
Returns a list of all standard SIP methods.
Converts a method to its string representation.
Types
@type t() :: atom()
Functions
Checks if a method is allowed to have a body.
Examples
iex> Parrot.Sip.Method.allows_body?(:invite)
true
iex> Parrot.Sip.Method.allows_body?(:ack)
true
Checks if a method can be canceled.
Examples
iex> Parrot.Sip.Method.can_cancel?(:invite)
true
iex> Parrot.Sip.Method.can_cancel?(:ack)
false
Checks if a method establishes a dialog.
Examples
iex> Parrot.Sip.Method.creates_dialog?(:invite)
true
iex> Parrot.Sip.Method.creates_dialog?(:register)
false
Checks if a method is a standard SIP method.
Examples
iex> Parrot.Sip.Method.is_standard?(:invite)
true
iex> Parrot.Sip.Method.is_standard?(:custom)
false
Converts a string to a method atom. For standard methods, returns a lowercase atom. For custom methods, returns an uppercase atom.
Examples
iex> Parrot.Sip.Method.parse("INVITE")
{:ok, :invite}
iex> Parrot.Sip.Method.parse("CUSTOM")
{:ok, :CUSTOM}
iex> Parrot.Sip.Method.parse(123)
{:error, :invalid_method}
Same as parse/1
but raises an error for invalid methods.
Examples
iex> Parrot.Sip.Method.parse!("INVITE")
:invite
iex> Parrot.Sip.Method.parse!("CUSTOM")
:CUSTOM
Checks if a method requires Contact header.
Examples
iex> Parrot.Sip.Method.requires_contact?(:invite)
true
iex> Parrot.Sip.Method.requires_contact?(:options)
false
@spec standard_methods() :: [atom()]
Returns a list of all standard SIP methods.
Examples
iex> Parrot.Sip.Method.standard_methods()
[:ack, :bye, :cancel, :info, :invite, :message, :notify, :options, :prack, :publish, :refer, :register, :subscribe, :update]
Converts a method to its string representation.
Examples
iex> Parrot.Sip.Method.to_string(:invite)
"INVITE"
iex> Parrot.Sip.Method.to_string(:CUSTOM)
"CUSTOM"