megaco(3)
okay bestie, welcome to megaco(3) β that's the Erlang Module Definition, section 3, and it's literally the main API of the Megaco application. we're doing this in seven parts because it's a lot, but we're gonna get through it together. no cap. π
β¨ NAME β¨
megaco β the main API of the Megaco application. that's it, that's the name. iykyk.
πΈ DESCRIPTION πΈ
Interface module for the Megaco application. it's the plug, the vibe, the whole point. periodt.
π¦ DATA TYPES π¦
so this type is a basic lookup key β an atom β for info on an active connection. the value can be literally anything. no pressure. π
conn_info_item() ::
control_pid | send_handle | local_mid | remote_mid |
receive_handle | trans_id | max_trans_id | request_timer |
long_request_timer | request_keep_alive_timeout |
long_request_resend | reply_timer | call_proxy_gc_timeout |
auto_ack | trans_ack | trans_ack_maxcount | trans_req |
trans_req_maxcount | trans_req_maxsize | trans_timer |
pending_timer | sent_pending_limit | recv_pending_limit |
send_mod | encoding_mod | encoding_config | protocol_version |
strict_version | reply_data | threaded | resend_indication |
segment_reply_ind | segment_recv_timer | segment_send |
max_pdu_size.
control_pidβ the pid of the process that's controlling a connection. like, the main character of that conn. π- Value type:
pid()
- Value type:
send_handleβ an opaque send handle β its insides are a secret between the send module and itself. π€«- Value type:
send_handle/0
- Value type:
local_midβ the local mid β that's the connection's own mid, the one it was born with. π- Value type:
mid/0
- Value type:
remote_midβ the remote mid β the other side's mid. the one you're talking to. π- Value type:
mid/0
- Value type:
receive_handleβ constructs amegaco_receive_handlerecord. fancy. β¨- Value type:
receive_handle/0
- Value type:
trans_idβ the next transaction id. but heads up: transaction ids are (currently) kept per user, so you can't be 100% sure that the value you get back will actually be used for a transaction on this connection β especially if a user has several connections, which is totally not unlikely. π- Value type:
transaction_id/0 | undefined_serial
- Value type:
max_trans_idβ the last transaction id. like, the final boss of transaction ids. π- Value type:
transaction_id/0 | infinity
- Value type:
request_timerβ wait for reply, bestie. when a reply comes in, the timer gets cancelled. when a pending message arrives, the timer is cancelled and thelong_request_timertakes over (see below). no resends from that point because we now know the other side got the request. when the timer hits an intermediate expire, the request is resent and the timer restarts. when it hits the final expire, eithermegaco:callreturns{error, timeout}or thehandle_trans_replycallback is called withUserReply = {error, timeout}(if you usedmegaco:cast).- Value type:
megaco_timer/0 - Defaults to
#megaco_incr_timer{}.
- Value type:
long_request_timerβ wait for reply after you've already gotten a pending message. when the timer hits an intermediate expire, the timer restarts. when a pending message comes in and thelong_request_timerisn't "on its final leg", the timer restarts, and iflong_request_resend = true, the request gets re-sent. π- Value type:
megaco_timer/0 - Defaults to 60 seconds.
- Value type:
request_keep_alive_timeoutβ sets the timeout for the request-keep-alive timer. this timer starts when the first reply to an async request (sent withmegaco:cast/3) shows up. while it's running, replies go to thehandle_trans_reply/4,5callback with their "arrival number" (checkUserReplyin that callback). replies that arrive after the timer expires go tohandle_unexpected_trans/3,4instead. π°οΈ- Value type:
plain | non_neg_integer() - Defaults to
plain.
- Value type:
long_request_resendβ this option says whether the request should be resent until the reply arrives, even if a pending message was already received. normally, after a pending message, we don't resend (because pending means they got it). but the reply can still get lost, so this behavior has its moments. and like, it's pointless to set this totrueunlesslong_request_timer(see above) is also an incremental timer (#megaco_incr_timer{}). π€·- Value type:
boolean() - Defaults to
false.
- Value type:
reply_timerβ wait for an ack. when a request comes in, some reply info gets stored internally (like the reply binary). that info sticks around until an ack arrives or this timer expires. so if the same request shows up again (same transaction id, say), megaco will automatically (re-)send the stored reply. if the timer is a#megaco_incr_timer{}, then for each intermediate timeout, the reply gets resent (until the ack arrives or the timer expires). π- Value type:
megaco_timer/0 - Defaults to 30000.
- Value type:
call_proxy_gc_timeoutβ timeout for the call proxy. when you send a request withcall/3, a proxy process starts to handle all the replies. after the reply is received and delivered, the proxy hangs around for as long as this option says. any messages it gets go to the user viahandle_unexpected_trans. the timeout is in milliseconds. a value of 0 means the proxy exits right after delivering the reply. bye bestie π- Value type:
non_neg_integer() - Defaults to 5000 (= 5 seconds).
- Value type:
auto_ackβ automatically send a transaction ack when the transaction reply is received (seetrans_ackbelow). this is for the three-way-handshake. π€- Value type:
boolean() - Defaults to
false.
- Value type:
trans_ackβ should acks be accumulated or not? this only matters ifauto_ackistrue. ifauto_ackistrueandtrans_ackisfalse, acks go out immediately. iftrans_ackistrue, acks go to the transaction sender process for accumulation and later sending (seetrans_ack_maxcount,trans_req_maxcount,trans_req_maxsize,trans_ack_maxcount, andtrans_timer). also check out "transaction sender" for more. π¦- Value type:
boolean() - Defaults to
false.
- Value type:
trans_ack_maxcountβ max number of accumulated acks. the transaction sender will hold at most this many (if it's started and set to accumulate acks). check "transaction sender" for more. π’- Value type:
non_neg_integer() - Defaults to 10.
- Value type:
trans_reqβ should requests be accumulated or not? iftrans_reqisfalse, requests go out immediately, each in its own message. iftrans_reqistrue, requests go to the transaction sender for accumulation and later sending (seetrans_ack_maxcount,trans_req_maxcount,trans_req_maxsize,trans_ack_maxcount, andtrans_timer). check "transaction sender" for more. π¨- Value type:
boolean() - Defaults to
false.
- Value type:
trans_req_maxcountβ max number of accumulated requests. the transaction sender will hold at most this many (if started and configured to accumulate requests). check "transaction sender" for more. ποΈ- Value type:
non_neg_integer() - Defaults to 10.
- Value type:
trans_req_maxsizeβ max size of the accumulated requests. the transaction sender will hold at most this much (if started and configured to accumulate requests). check "transaction sender" for more. π- Value type:
non_neg_integer() - Defaults to 2048.
- Value type:
trans_timerβ transaction sender timeout. it does two things. first, if it's 0, transactions are not accumulated (so the transaction sender process isn't even started). second, if it's greater than 0 and either (auto_ackandtrans_ackare true) ortrans_reqis true, the transaction sender starts and transactions get accumulated (depending onauto_ack,trans_ack, andtrans_req) for later sending. check "transaction sender" for more. β²οΈ- Value type:
non_neg_integer() - Defaults to 0.
- Value type:
pending_timerβ automatically send a transaction pending if the timer expires before a transaction reply is sent. this is also called the provisional response timer. β³- Value type:
megaco_timer/0 - Defaults to 30000 (= 30 seconds).
- Value type:
sent_pending_limitβ sent pending limit (check theMGOriginatedPendingLimitandMGCOriginatedPendingLimitin the megaco root package). this says how many pending messages can be sent for a given received transaction request. if you go over the limit, the transaction is aborted (seehandle_trans_request_abort) and an error message is sent to the other side. note: this does not affect the actual sending of pending transactions. that's either implicit (like when a re-sent transaction request comes in for a request already being processed) or controlled bypending_timer, see above. π«
that's part 1, bestie! part 2 is on its way, don't go anywhere π
Value type: pos_integer() | infinity
Defaults to infinity.
Okay bestie, that was the tail end of the last field, now let's keep it moving! π
recv_pending_limitβ Receive pending limit (see theMGOriginatedPendingLimitand theMGCOriginatedPendingLimitof the megaco root package). This parameter specifies how many pending messages that can be received (for a sent transaction request). When the limit is exceeded, the transaction is considered lost, and an error returned to the user (through the call-back functionhandle_trans_reply). π
Value type: pos_integer() | infinity
Defaults to: infinity.
send_modβ Send callback module which exportssend_message/2. The functionSendMod:send_message(SendHandle, Binary)is invoked when the bytes needs to be transmitted to the remote user. π
Value type: module().
Defaults to: megaco_tcp.
encoding_modβ Encoding callback module which exportsencode_message/2anddecode_message/2. The functionEncodingMod:encode_message(EncodingConfig, MegacoMessage)is invoked whenever a'MegacoMessage'record needs to be translated into an Erlang binary. The functionEncodingMod:decode_message(EncodingConfig, Binary)is invoked whenever an Erlang binary needs to be translated into a'MegacoMessage'record. β¨
Value type: module().
Defaults to: megaco_pretty_text_encoder.
encoding_configβ Encoding module config.
Value type: loist(). (yes, that's spelled loist() in the original, no cap)
Defaults to: [].
protocol_versionβ Actual protocol version.
Value type: protocol_version/0
Defaults to: 1.
strict_versionβ Strict version control, i.e. when a message is received, verify that the version is that which was negotiated. π
Value type: boolean()
Defaults to: true.
reply_dataβ Default reply data.
Value type: term()
Defaults to: undefined.
threadedβ If a received message contains several transaction requests, this option indicates whether the requests should be handled sequentially in the same process (false), or if each request should be handled by its own process (truei.e. a separate process is spawned for each request). π§΅
Value type: boolean()
Defaults to: false.
resend_indicationβ This option indicates whether the transport module should be told if a message send is a resend or not.
If false, megaco messages are sent using the send_message/2 function.
If true, megaco message re-sends are made using the resend_message function. The initial message send is still done using the send_message function.
The special value flag instead indicates that the function send_message/3 shall be used. π©
Value type: flag | boolean()
Defaults to: false.
segment_reply_indβ This option specifies if the user shall be notified of received segment replies or not.
See handle_segment_reply callback function for more information.
Value type: boolean()
Defaults to: false.
segment_recv_timerβ This timer is started when the segment indicated by the segmentation complete token (e.g. the last of the segment which makes up the reply) is received, but all segments has not yet been received. β³
When the timer finally expires, a "megaco segments not received" (459) error message is sent to the other side and the user is notified with a segment timeout UserReply in either the handle_trans_reply callback function or the return value of the call/2 function.
Value type: megaco_timer/0
Defaults to: 10000 (= 10 seconds).
segment_sendβ Shall outgoing messages be segmented or not.
Value type: none | pos_integer() | infinity
noneβ Do not segment outgoing reply messages. This is useful when either it is known that messages are never too large or that the transport protocol can handle such things on its own (e.g. TCP or SCTP).pos_integer/0β Outgoing reply messages will be segmented as needed (seemax_pdu_sizebelow). This value, K, indicate the outstanding window, i.e. how many segments can be outstanding (not acknowledged) at any given time.infinityβ Outgoing reply messages will be segmented as needed (seemax_pdu_sizebelow). Segment messages are sent all at once (i.e. no acknowledgement awaited before sending the next segment).
Defaults to: none.
max_pdu_sizeβ Max message size. If the encoded message (PDU) exceeds this size, the message should be segmented, and then encoded. π¦
Value type: infinity | pos_integer()
Defaults to: infinity.
And now, bestie, let's get into the type aliases! These are like the little building blocks, iykyk. π
counter()βmedGwyGatewayNumTimerRecovery | medGwyGatewayNumErrors.counter_value()βnon_neg_integer().digit_map_event()βmegaco_digit_map:event().digit_map_kind()βmegaco_digit_map:kind().digit_map_letter()βmegaco_digit_map:letter().digit_map_value()βmegaco_digit_map:value().error_desc()βmegaco_encoder:error_desc().global_counter()βmedGwyGatewayNumErrors.megaco_message()βmegaco_encoder:megaco_message().megaco_timer()βmegaco_user:megaco_timer().mid()β The Megaco Identifier. π
mid() ::
{ip4Address, megaco_encoder:ip4Address()} |
{ip6Address, megaco_encoder:ip6Address()} |
{domainName, megaco_encoder:domainName()} |
{deviceName, megaco_encoder:deviceName()} |
{mtpAddress, megaco_encoder:mtpAddress()}.
property_group()βmegaco_sdp:property_group().property_groups()βmegaco_sdp:property_groups().property_parm()βmegaco_sdp:property_parm().protocol_version()βmegaco_encoder:protocol_version().receive_handle()βmegaco_user:receive_handle().sdp()βmegaco_sdp:sdp().sdp_property_group()βmegaco_sdp:sdp_property_group().sdp_property_groups()βmegaco_sdp:sdp_property_groups().sdp_property_parm()βmegaco_sdp:sdp_property_parm().segment_no()βmegaco_encoder:segment_no().send_handle()β Opaque send handle whose contents is internal for the send module. May be any term.
Value type: term().
system_info_item()β System info items. π οΈ
system_info_item() ::
text_config | connections | users | n_active_requests |
n_active_replies | n_active_connections | reply_counters |
pending_counters.
text_configβ The text encoding config.
Value type: term()
connectionsβ Lists all active connections. Returns a list ofmegaco_conn_handlerecords.
Value type: [conn_handle/0]
usersβ Lists all active users.
Value type: [mid/0]
n_active_requestsβ Returns number of requests that has originated from this Erlang node and still are active (and therefore consumes system resources).
Value type: non_neg_integer()
n_active_repliesβ Returns the number of replies that has originated from this Erlang node and still are active (and therefore consumes system resources).
Value type: non_neg_integer()
n_active_connectionsβ Returns the number of active connections.
Value type: non_neg_integer()
reply_countersβ Returns a list of the reply counters.
Value type: {conn_handle/0, transaction_id/0, [non_neg_integer()]}
pending_countersβ Returns a list of the receive and sent pending counters.
Value type: {recv | sent, [{transaction_id/0, [non_neg_integer()]}]}
trace_data()β The trace data passed to the trace handler fun (in the second argument) and returned by same. For instance this could be a file descriptor, that the trace handler fun can use to print the event to a file. π
Value type: term().
trace_event()β The trace event generated bydbg.
Value type: term().
trace_handler()β The trace handler fun is used to"process"each trace event (for instance print to file or to stdout after formating). π
trace_handler() ::
fun((trace_event(), trace_data()) -> trace_data()).
trace_level()β How much trace events should be produced.min(=0) means no trace events are produced, which is the default.
Value type: min | max | 0..100.
transaction_id()βpos_integer().transaction_reply()βmegaco_encoder:transaction_reply().user_info_item()β
user_info_item() ::
connections | receive_handle | trans_id | min_trans_id |
max_trans_id | request_timer | long_request_timer |
long_request_resend | reply_timer |
request_keep_alive_timeout | call_proxy_gc_timeout |
auto_ack | trans_ack | trans_ack_maxcount | trans_req |
trans_req_maxcount | trans_req_maxsize | trans_timer |
pending_timer | sent_pending_limit | recv_pending_limit |
send_mod | encoding_mod | encoding_config | protocol_version |
strict_version | reply_data | user_mod | user_args |
threaded | resend_indication | segment_reply_ind |
segment_recv_timer | segment_send | max_pdu_size.
connectionsβ Lists all active connections for this user. Returns a list ofmegaco_conn_handlerecords.
Value type: [conn_handle/0]
receive_handleβ Construct areceive_handlefrom user config.
Value type: receive_handle/0
trans_idβ Current transaction id.
Value type: transaction_id/0 | undefined_serial
min_trans_idβ First transaction id.
Value type: transaction_id/0
Defaults to: 1.
max_trans_idβ Last transaction id.
Value type: transaction_id/0 | infinity
Defaults to: infinity.
request_timerβ Wait for reply.
The timer is cancelled when a reply is received.
When a pending message comes in, the timer gets cancelled and long_request_timer takes over instead (peep below π). From that point on there are no resends, periodt β because now we know the other side got the request. π«Ά
When the timer hits an intermediate expire, the request gets resent and the timer restarts. π
When the timer hits the final expire, it's one of two things: either megaco:call returns with {error, timeout}, or the callback function handle_trans_reply gets called with UserReply = {error, timeout} (that's the case if you used megaco:cast). π
Value type: megaco_timer/0
Defaults to #megaco_incr_timer{}.
long_request_timerβ The wait-for-reply clock after you've already received a pending message. π°οΈ
When the timer reaches an intermediate expire, the timer is simply restarted.
When a pending message arrives and the long_request_timer is not "on its final leg", the timer restarts, and, if long_request_resend = true, the request gets re-sent. β¨
Value type: megaco_timer/0
Defaults to 60000 (= 60 seconds).
long_request_resendβ Whether the request should be re-sent until the reply shows up, even though a pending message already landed. π
Normally, once a pending message has been received, the request is not resent (because a pending message is basically the other side saying "yeah I got it"). But since the reply (to that request) can totally get lost, this behaviour does have its values.
It is of course pointless to set this value to true unless long_request_timer (see above) is also set to an incremental timer (#megaco_incr_timer{}).
Value type: boolean()
Defaults to false.
reply_timerβ Wait for an ack. π€
When a request comes in, some info related to the reply is stored internally (e.g. the binary of the reply). This info lives until either an ack is received or this timer expires. So for instance, if the same request shows up again (e.g. a request with the same transaction id), the (stored) reply gets (re-)sent automatically by megaco. no cap.
If the timer is of type #megaco_incr_timer{}, then for every intermediate timeout, the reply gets resent (this holds until the ack is received or the timer expires).
Value type: megaco_timer/0
Defaults to 30 seconds.
request_keep_alive_timeoutβ The timeout time for the request-keep-alive timer. π
This timer kicks off when the first reply to an asynchronous request (one issued with the megaco:cast/3 function) arrives. As long as this timer is running, replies get delivered via the handle_trans_reply/4,5 callback function, together with their "arrival number" (see UserReply of the handle_trans_reply/4,5 callback function).
Replies that show up after the timer has expired get delivered using the handle_unexpected_trans/3,4 callback function instead. π
Value type: plain | non_neg_integer()
Defaults to plain.
call_proxy_gc_timeoutβ Timeout time for the call proxy. π§Ή
When a request is sent using the call/3 function, a proxy process starts up to handle all the replies. Once the reply has been received and delivered to the user, that proxy process keeps existing for as long as this option says. Any messages it receives in that window get passed on to the user via the handle_unexpected_trans callback function.
The timeout time is in milliseconds. A value of 0 (zero) means the proxy process exits directly right after the reply has been delivered.
Value type: pos_integer()
Defaults to 5000 (= 5 seconds).
auto_ackβ Automatic send transaction ack once the transaction reply has been received (seetrans_ackbelow). π
This is what's used for the three-way-handshake.
Value type: boolean()
Defaults to false.
trans_ackβ Shall ack's be accumulated or not. π€
This property is only valid if auto_ack is true.
If auto_ack is true, then if trans_ack is false, ack's get sent immediately. If trans_ack is true, then ack's instead get sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).
See also transaction sender for more info.
Value type: boolean()
Defaults to false.
trans_ack_maxcountβ Maximum number of accumulated ack's. At most this many ack's get accumulated by the transaction sender (if it's started and configured to accumulate ack's). π¦
See also transaction sender for more info.
Value type: integer()
Defaults to 10.
trans_reqβ Shall requests be accumulated or not. ποΈ
If trans_req is false, then request(s) get sent immediately (in their own message).
If trans_req is true, then request(s) instead get sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).
See also transaction sender for more info.
Value type: boolean()
Defaults to false.
trans_req_maxcountβ Maximum number of accumulated requests. At most this many requests get accumulated by the transaction sender (if it's started and configured to accumulate requests). β¨
See also transaction sender for more info.
Value type: integer()
Defaults to 10.
trans_req_maxsizeβ Maximum size of the accumulated requests. At most this much requests get accumulated by the transaction sender (if it's started and configured to accumulate requests). πΈ
See also transaction sender for more info.
Value type: integer()
Defaults to 2048.
trans_timerβ Transaction sender timeout time. It does two jobs. First: if the value is0, then transactions will not be accumulated (i.e. the transaction sender process will not be started). Second: if the value is greater than0, andauto_ackandtrans_ackare bothtrueortrans_reqistrue, then the transaction sender gets started and transactions (depending on the values ofauto_ack,trans_ackandtrans_req) get accumulated, for later sending. π
See also transaction sender for more info.
Value type: integer()
Defaults to 0.
pending_timerβ Automatically send pending if the timer expires before a transaction reply has been sent. This timer is also called the provisional response timer. β³
Value type: megaco_timer/0
Defaults to 30000.
sent_pending_limitβ Sent pending limit (see theMGOriginatedPendingLimitand theMGCOriginatedPendingLimitof themegacoroot package). This parameter says how many pending messages can be sent (for a given received transaction request). When the limit is exceeded, the transaction is aborted (seehandle_trans_request_abort) and an error message gets sent to the other side. π¨
Note that this has no effect on the actual sending of pending transactions. That's either implicit (e.g. when receiving a re-sent transaction request for a request which is being processed) or controlled by the pending_timer, see above.
Value type: infinity | pos_integer()
Defaults to infinity.
recv_pending_limitβ Receive pending limit (see theMGOriginatedPendingLimitand theMGCOriginatedPendingLimitof themegacoroot package). This parameter says how many pending messages can be received (for a sent transaction request). When the limit is exceeded, the transaction is considered lost, and an error is returned to the user (through the call-back functionhandle_trans_reply). π
Value type: infinity | pos_integer()
Defaults to infinity.
send_modβ The send callback module, which exportssend_message/2. The functionSendMod:send_message(SendHandle, Binary)gets invoked when the bytes need to be transmitted to the remote user. π‘
Value type: module()
Defaults to megaco_tcp.
encoding_modβ The encoding callback module, which exportsencode_message/2anddecode_message/2. The functionEncodingMod:encode_message(EncodingConfig, MegacoMessage)gets invoked whenever a'MegacoMessage'record needs to be translated into an Erlang binary. The functionEncodingMod:decode_message(EncodingConfig, Binary)gets invoked whenever an Erlang binary needs to be translated into a'MegacoMessage'record. π¦
Value type: module()
Defaults to megaco_pretty_text_encoder.
encoding_configβ Config for the encoding module. π
Value type: list()
Defaults to [].
protocol_versionβ Actual protocol version. π
Value type: protocol_version/0
Defaults to 1.
strict_versionβ Strict version control, i.e. when a message is received, verify that the version is the one that was negotiated. π΅οΈββοΈ
Value type: boolean()
Defaults to true.
reply_dataβ Default reply data. π
Value type: term()
Defaults to undefined.
user_modβ Name of the user callback module. See the the reference manual formegaco_userfor more info. π
Value type: module()
Has no default value since it's a mandatory config option. (Not optional bestie, it's required. π )
user_argsβ List of extra arguments to the user callback functions. See the the reference manual formegaco_userfor more info. β¨
Value type: list()
threadedβ so like, if a message you receive has multiple transaction requests packed in itβ¦ do we handle them one at a time in the same process (false), or does each request get its own glow-up process (true, meaning a fresh process is spawned for every single request)? Your call bestie.
Value type: boolean()
Defaults to false.
resend_indicationβ this one's about telling the transport module whether a message send is a resend or not. (Yes, the original says "weather" but we both know it means whether π)
If false, megaco messages go out using the send_message function.
If true, megaco message re-sends go out using the resend_message function. The very first send still uses send_message tho.
And the special value flag means the function send_message/3 shall be used instead.
Value type: boolean()
Defaults to false.
segment_reply_indβ do you wanna be notified about received segment replies or not? That's the whole vibe.
See the handle_segment_reply callback function for more tea.
Value type: boolean()
Defaults to false.
segment_recv_timerβ this timer kicks off the moment the segment marked by the segmentation complete token arrives, but you still haven't received all the segments. It's giving waiting-for-the-group-chat energy.
When it finally expires, a "megaco segments not received" (459) error message is sent to the other side, and you get notified with a segment timeout UserReply β either in the handle_trans_reply callback function or as the return value of the call/3 function.
Value type: megaco_timer/0
Defaults to 10000.
segment_sendβ shall outgoing messages be segmented, or not? π
Value type: none | pos_integer() | infinity
noneβ do NOT segment outgoing reply messages. This is the move when you know messages are never too large, or when the transport protocol can handle that kind of thing all by itself (e.g.TCPorSCTP).pos_integer/0β outgoing reply messages will be segmented as needed (seemax_pdu_sizebelow). This value,K, is the outstanding window β like, how many segments can be outstanding (not acknowledged) at any given time.infinityβ outgoing reply messages will be segmented as needed (seemax_pdu_sizebelow). Segment messages get sent all at once (i.e. no acknowledgement awaited before sending the next segment).
Defaults to none.
max_pdu_sizeβ the max message size, periodt. If the encoded message (PDU) exceeds this size, the message should be segmented, and then encoded.
Value type: infinity | pos_integer()
Defaults to infinity.
void() :: term().
This type is what you use when a function's return is justβ¦ to be ignored. no thoughts, head empty π
π FUNCTIONS π
call(ConnHandle, ActionRequests, SendOptions) -> {ProtocolVersion, UserReply | [UserReply]}
call(ConnHandle, ActionRequests, SendOptions) ->
{ProtocolVersion, UserReply | [UserReply]}
when
ConnHandle :: conn_handle(),
ActionRequests :: action_reqs() | [action_reqs()],
SendOptions :: [SendOption],
SendOption ::
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{protocol_version, protocol_version()} |
{call_proxy_gc_timeout, non_neg_integer()},
ProtocolVersion :: protocol_version(),
UserReply :: Success | Failure,
Success :: {ok, Result} | {ok, Result, SuccessExtra},
Result :: MessageResult | SegmentResult,
MessageResult :: action_reps(),
SegmentResult :: SegmentsOk,
SegmentsOk :: [{segment_no(), action_reps()}],
Failure ::
{error, Reason} | {error, Reason, ErrorExtra},
Reason ::
MessageReason | SegmentReason | UserCancelReason |
SendReason | OtherReason,
MessageReason :: error_desc(),
SegmentReason ::
{segment, SegmentsOk, SegmentsErr} |
{segment_timeout, MissingSegments, SegmentsOk,
SegmentsErr},
SegmentsErr :: {segment_no(), error_desc()},
MissingSegments :: [segment_no()],
UserCancelReason :: {user_cancel,
ReasonForUserCancel},
ReasonForUserCancel :: term(),
SendReason :: SendCancelledReason | SendFailedReason,
SendCancelledReason ::
{send_message_cancelled, term()},
SendFailedReason :: {send_message_failed, term()},
OtherReason ::
{wrong_mid,
WrongMid :: mid(),
RightMid :: mid(),
transaction_reply()} |
term(),
SuccessExtra :: term(),
ErrorExtra :: term().
Sends one or more transaction request(s) and then waits for the reply. Iconic behaviour honestly.
When you're sending one transaction in a message, ActionRequests should be action_reqs/0 (and then the reply will be UserReply). When you're sending several transactions in one message, ActionRequests should be [action_reqs()] (and then the reply will be [UserReply]). Each element of that list is part of one transaction.
For some of our codecs (not binary, bestie), you can also pre-encode the actions β in which case ActionRequests will be either a binary/0 or [binary()]. Slay.
The function returns when the reply arrives, when the request timer eventually times out, or when the outstanding requests get explicitly cancelled.
The default values of the send options are obtained by megaco:conn_info(ConnHandle, Item). But the send options above may explicitly be overridden. Yes ma'am.
The ProtocolVersion version is the version actually encoded in the reply message.
At Success, the UserReply contains a list of 'ActionReply' records possibly containing error indications. π
A Failure means the remote user replied with an explicit transactionError.
A UserCancelReason means the request got canceled by the user. ReasonForUserCancel is the reason given in the call to the cancel/2 function.
A send error (SendReason) means the send function of the megaco transport callback module failed to send the request. There are two separate cases here: SendCancelledReason and SendFailedReason. The first is the result of the send function returning {cancel, Reason}, and the second is some other kind of erroneous return value. See the send_message function for more info.
An OtherReason means some other error, like a timeout. π
For more info about the 'extra' part of the result (SuccessExtra and ErrorExtra), see the note in the user callback module documentation.
cancel(ConnHandle, CancelReason) -> ok | {error, Reason}
cancel(ConnHandle, CancelReason) -> ok | {error, Reason}
when
ConnHandle :: conn_handle(),
CancelReason :: term(),
Reason :: term().
Cancel all outstanding messages for this connection. The ultimate "never mind, I take it back" β¨
This causes outstanding megaco:call/3 requests to return. The callback functions UserMod:handle_reply/4 and UserMod:handle_trans_ack/4 are also invoked where it applies. See the megaco_user module for more info about the callback arguments.
cast(ConnHandle, ActionRequests, SendOptions) -> ok | {error, Reason}
cast(ConnHandle, ActionRequests, SendOptions) ->
ok | {error, Reason}
when
ConnHandle :: conn_handle(),
ActionRequests :: action_reqs() | [action_reqs()],
SendOptions :: [SendOption],
SendOption ::
{request_keep_alive_timeout,
RequestKeepAliveTimer} |
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{reply_data, ReplyData} |
{protocol_version, ProtocolVersion},
RequestKeepAliveTimer :: plain | non_neg_integer(),
ReplyData :: term(),
ProtocolVersion :: protocol_version(),
Reason :: term().
Sends one or more transaction request(s) but does NOT wait for a reply.</pruple> The "hit send and dip" of the megaco world π
When you're sending one transaction in a message, ActionRequests should be action_reqs/0. When you're sending several transactions in a message, ActionRequests should be [action_reqs()]. Each element of the list is part of one transaction.
For some of our codecs (not binary), you can also pre-encode the actions β in which case Actions will be either a binary/0 or [binary()].
The default values of the send options are obtained by megaco:conn_info(ConnHandle, Item). But the send options above may explicitly be overridden.
The ProtocolVersion version is the version actually encoded in the reply message.
The callback function UserMod:handle_trans_reply/4 is invoked when the reply arrives, when the request timer eventually times out, or when the outstanding requests get explicitly cancelled. See the megaco_user module for more info about the callback arguments.
Given as the ReplyData argument to UserMod:handle_trans_reply/4.
conn_info(ConnHandle, ConnInfo) -> Value
conn_info(ConnHandle, ConnInfo) -> Value
when
ConnHandle :: conn_handle(),
ConnInfo ::
all | requests | replies | conn_info_item(),
Value :: term().
Lookup information about an active connection. Requires that the connection is active, no cap.
Failure: exit if, for instance, ConnHandle refers to a connection that no longer exists. π
connect/5 β establish a "virtual" connection π
connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid, Extra) ->
{ok, ConnHandle} | {error, Reason}
when
ReceiveHandle :: receive_handle(),
RemoteMid :: preliminary_mid | mid(),
SendHandle :: send_handle(),
ControlPid :: pid(),
Extra :: term(),
ConnHandle :: conn_handle(),
Reason ::
ConnectReason | HandleConnectReason | term(),
ConnectReason ::
{no_such_user, LocalMid} |
{already_connected, ConnHandle} |
term(),
LocalMid :: mid(),
HandleConnectReason ::
{connection_refused, ConnData, ErrorInfo} |
term(),
ConnData :: term(),
ErrorInfo :: term().
Okay so connect/5 is literally how you activate a connection to a remote user. Once that's done, you can send messages with SendMod:send_message/2. ControlPid is the pid of the process that controls the connection. That process gets supervised, and if it dies, the app detects it and calls UserMod:handle_disconnect/2. Peep megaco_user for the callback deets. You can also explicitly deactivate the connection by calling megaco:disconnect/2.
ControlPid can be a process on another Erlang node. That's useful when you want to distribute a user over several Erlang nodes. In that case, one of the nodes has the physical connection. When a user on one of the other nodes needs to send a request (with megaco:call/3 or megaco:cast/3), the message gets encoded on the originating Erlang node and then forwarded to the node with the physical connection. When the reply arrives, it gets forwarded back to the originator. The distributed connection can be explicitly deactivated by a local call to megaco:disconnect/2, or implicitly when the physical connection is deactivated β with megaco:disconnect/2, killing the controlling process, halting the other node, ... π
Calling this function triggers UserMod:handle_connect/2. Again, megaco_user has the callback tea. π«
A connection can be established in a few different ways:
- provisioned MID β the MG can explicitly invoke
megaco:connect/4and use a provisioned MID of the MGC as theRemoteMid. - upgrade preliminary MID β the MG can explicitly invoke
megaco:connect/4with the atompreliminary_midas a temporary MID of the MGC, send an initial message β the Service Change Request β to the MGC, and then wait for an initial message β the Service Change Reply. When the reply arrives, the Megaco application picks the MID of the MGC from the message header and automatically upgrades the connection to a "normal" connection. With this method,UserMod:handle_connect/2gets invoked twice: first with aConnHandlewhoseremote_midfield is set topreliminary_mid, and then after the upgrade with theremote_midfield set to the actual MID of the MGC. - automatic β when the MGC receives its first message, the Service Change Request, the Megaco application automatically establishes the connection by using the MG MID found in the message header as the remote mid.
- distributed β when a user (MG/MGC) is distributed over several nodes, the node hosting the connection must already have activated the connection and it must be in the "normal" state.
RemoteMidmust be a real Megaco MID and not apreliminary_mid.
An initial megaco_receive_handle record may be obtained with megaco:user_info(UserMid, receive_handle).
The send handle is provided by the preferred transport module, e.g. megaco_tcp, megaco_udp. Read the documentation about each transport module for the details.
The connect is done in two steps: first an internal connection setup, then calling the user handle_connect callback. The first step can fail with Reason = ConnectReason, and the second can fail with Reason = HandleConnectReason:
ConnectReasonβ an error with this reason is generated by the megaco application itself.HandleConnectReasonβ an error with this reason is caused by the userhandle_connectcallback function either returning an error or an invalid value.
Extra can be any term/0 except the atom ignore_extra. It is passed (back) to the user via the callback function handle_connect/3.
decode_sdp/1 β decode (parse) a property parameter construct π§
decode_sdp(PP) -> {ok, SDP} | {error, Reason}
when
PP ::
property_parm() |
property_group() |
property_groups() |
asn1_NOVALUE,
SDP ::
sdp() |
DecodeSdpPropertyGroup |
DecodeSdpPropertyGroups | asn1_NOVALUE,
DecodeSdpPropertyGroup :: [DecodeSDP],
DecodeSdpPropertyGroups ::
[DecodeSdpPropertyGroup],
DecodeSDP ::
sdp() | {property_parm(), DecodeError},
DecodeError :: term(),
Reason :: term().
When decoding property_group/0 or property_groups/0, those property parameter constructs that cannot be decoded β either because of a decode error or because they are unknown β come back as a two-tuple. The first element is the (undecoded) property parameter, and the second is the actual reason. That means anyone calling this function has to expect not just sdp records, but also this two-tuple construct. π
This function performs the following transformations:
property_parm()->sdp()property_group()->sdp_property_group()property_groups()->sdp_property_groups()
disable_trace/0 β stop megaco tracing π
disable_trace() -> void().
This function is used to stop megaco tracing. Periodt.
disconnect/2 β tear down a "virtual" connection π
disconnect(ConnHandle, DiscoReason) -> ok | {error, ErrReason}
when
ConnHandle :: conn_handle(),
DiscoReason :: term(),
ErrReason :: term().
Tear down a "virtual" connection. This causes the UserMod:handle_disconnect/2 callback function to be invoked. See the megaco_user module for more info about the callback arguments.
enable_trace/2 β start tracing at a level β¨
enable_trace(Level, Destination) -> void()
when
Level :: trace_level(),
Destination :: File | Port | HandlerSpec | io,
File :: string(),
Port :: integer(),
HandlerSpec :: {HandlerFun, InitialData},
HandlerFun :: trace_handler(),
InitialData :: trace_data().
This function is used to start megaco tracing at a given Level and direct the result to the given Destination. It starts a tracer server and then sets the proper match spec according to Level.
- When
DestinationisFile, the printable megaco trace events are printed to the fileFileusing plainio:format/2. - When
Destinationisio, the printable megaco trace events are printed on stdout using plainio:format/2.
See dbg for further information.
encode_actions/3 β encode action requests for one or more transaction request(s) π₯
encode_actions(ConnHandle, ActionRequests, Options) ->
{ok, Result} | {error, Reason}
when
ConnHandle :: conn_handle(),
ActionRequests ::
action_reqs() | [action_reqs()],
Options :: [Option],
Option ::
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{protocol_version, protocol_version()},
Result :: binary() | [binary()],
Reason :: term().
Encodes lists of action requests for one or more transaction request(s). When encoding action requests for one transaction, Actions should be action_reqs/0. When encoding action requests for several transactions, Actions should be [action_reqs()]. Each element of the list is part of one transaction.
encode_sdp/1 β encode (generate) an SDP construct π
encode_sdp(SDP) -> {ok, PP} | {error, Reason}
when
SDP ::
sdp_property_parm() |
sdp_property_group() |
sdp_property_groups() |
asn1_NOVALUE,
PP ::
property_parm() |
property_group() |
property_groups() |
asn1_NOVALUE,
Reason :: term().
Encode (generate) an SDP construct. If a property_parm/0 is found as part of the input (SDP), then it is left unchanged.
This function performs the following transformations:
sdp()->property_parm()sdp_property_group()->property_group()sdp_property_groups()->property_groups()
πΈ eval_digit_map/2 β the digit map girly β¨
eval_digit_map(DigitMap, Timers) ->
{ok, MatchResult} | {error, Reason}
when
DigitMap ::
digit_map_value() | ParsedDigitMap,
ParsedDigitMap :: term(),
Timers :: Ignore | Reject,
Ignore ::
ignore | {ignore, digit_map_value()},
Reject ::
reject |
{reject, digit_map_value()} |
digit_map_value(),
MatchResult ::
{Kind, Letters} | {Kind, Letters, Extra},
Kind :: digit_map_kind(),
Letters :: [digit_map_letter()],
Extra :: digit_map_letter(),
Reason :: term().
Okay so what this does is collect digit map letters, going by the digit map. π
When you're evaluating a digit map, a state machine sits there waiting for timeouts and for letters that come in via megaco:report_digit_event/2. How long each of those timeouts lasts? That's all defined in the digit_map_value() record, bestie. π
Once a full sequence of valid events has arrived, you get the result back as a list of letters. slay.
Now β syntax errors. There's two ways to handle them (aka when an unexpected event shows up while the digit map evaluator is expecting literally anything else π). You can either ignore the unexpected events or reject them. Rejecting means the evaluation gets aborted and an error comes back at you. Choose wisely, fr fr.
π«Ά get_stats/0, get_stats/1 and get_stats/2 β the stats besties
get_stats() -> {ok, [TotalStats]} | {error, Reason}
when
TotalStats ::
{conn_handle(), [Stats]} |
{global_counter(), counter_value()},
Stats :: {counter(), counter_value()},
Reason :: term().
Retrieve all the (SNMP) statistic counters that the megaco application is keeping track of. β¨
The global counters handle the events that can't be pinned to a single connection (think protocol errors that happen before the connection has even been properly set up β awkward π).
get_stats(GCounter) -> {ok, Value} | {error, Reason}
when
GCounter :: global_counter(),
Value :: counter_value(),
Reason :: term();
(ConnHandle) -> {ok, [Stats]} | {error, Reason}
when
ConnHandle :: conn_handle(),
Stats :: {counter(), counter_value()},
Reason :: term().
Version one: retrieve a (SNMP) (global) statistic counter that the megaco application maintains. Again, global counters are for the events that can't be blamed on one connection (like protocol errors before the connection was properly set up π).
Version two: retrieve all the (SNMP) statistic counters the megaco application maintains, but for one specific connection. π
get_stats(ConnHandle, Counter) -> {ok, Value} | {error, Reason}
when
ConnHandle :: conn_handle(),
Counter :: counter(),
Value :: counter_value(),
Reason :: term().
Retrieve a single (SNMP) statistic counter that the megaco application maintains. One counter, one handle, no cap. β¨
π¦ info/0 β the everything bagel of info
info() -> Info
when
Info :: [{Key, Value}], Key :: atom(), Value :: term().
This function hands you a list of information about the megaco application. Like users and their config, connections and their config, statistics, and so on and so forth. π
Technically you could get all of this from user_info/2, conn_info/2, system_info/1 and get_stats/2 β but this is the low-effort, one-and-done way to get it all at once. We love convenience. π
π parse_digit_map/1 β parses a digit map body
parse_digit_map(DigitMapBody) ->
{ok, ParsedDigitMap} | {error, Reason}
when
DigitMapBody :: string(),
ParsedDigitMap :: term(),
Reason :: term().
Parses a digit map body. β¨
It takes a digit map body, represented as a list of characters, and turns it into a list of state transitions that are suited to be evaluated by megaco:eval_digit_map/1,2. Obsessed with a clean pipeline ngl.
π print_version_info/1 β pretty printing the versions
print_version_info(Versions) -> void()
when
Versions :: [VersionInfo],
VersionInfo :: term().
A lil utility function that produces a formatted printout of the versions info that the versions1 and versions2 functions generate. π¨οΈβ¨
Heads up: the function print_version_info/0 uses the result of the function version1/0 as VersionInfo.
Example, bestie:
{ok, V} = megaco:versions1(), megaco:format_versions(V).
π process_received_message/5 β where the messages get handled
process_received_message(ReceiveHandle, ControlPid, SendHandle,
BinMsg, Extra) ->
ok
when
ReceiveHandle :: receive_handle(),
ControlPid :: pid(),
SendHandle :: send_handle(),
BinMsg :: binary(),
Extra :: term().
Process a received message. π
This function is meant to be invoked by some transport module when it gets an incoming message. Which transport actually gets used? That's entirely up to the user to choose. Main character energy, your call. π
The message arrives as an Erlang binary and gets decoded by the encoding module stated in the receive handle, together with its encoding config (which is also in the receive handle, iykyk). Depending on how the decoding goes, different callback functions get invoked. Check out megaco_user for more info on the callback arguments.
The argument Extra is just an opaque data structure that gets passed to the user through the callback functions in the user callback module. But note: if Extra has the value extra_undefined, the argument gets ignored (same as if process_received_message/4 had been called instead). See the docs for the behaviour of the callback module, megaco_user, for more deets.
Also important: all processing happens in the context of the calling process. A transport module could call this function via one of the spawn functions (likespawn_opt). See alsoreceive_message/4,5. πΈ
If the message can't be decoded, this callback function gets invoked:
UserMod:handle_syntax_error/3
If the decoded message, instead of transactions, contains a message error, this callback function gets invoked:
UserMod:handle_message_error/3
If the decoded message happens to arrive before the connection is established, a brand new "virtual" connection gets established. This is typically what happens for the Media Gateway Controller (MGC) upon the first Service Change. When that goes down, this callback function gets invoked:
UserMod:handle_connect/2
For each transaction request in the decoded message, this callback function gets invoked:
UserMod:handle_trans_request/3
For each transaction reply in the decoded message, the reply gets returned to the user. Either the originating function megaco:call/3 returns, or β if the originating function was megaco:case/3 β this callback function gets invoked:
UserMod:handle_trans_reply/4
When a transaction acknowledgement is received, it's possible that the user has decided not to bother about the acknowledgement. But if the return value from UserMod:handle_trans_request/3 says the acknowledgement is important, this callback function gets invoked:
UserMod:handle_trans_ack/4
See the megaco_user module for more info about the callback arguments. π«Ά
π§ receive_message/5 β the spawn-y sibling
receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg,
Extra) ->
ok
when
ReceiveHandle :: receive_handle(),
ControlPid :: pid(),
SendHandle :: send_handle(),
BinMsg :: binary(),
Extra :: term().
Process a received message. π
This is a callback function intended to be invoked by some transport module when it gets an incoming message. Which transport actually gets used is up to the user to choose.
In principle, this function calls the process_received_message/4,5 function via a spawn to do the actual processing. Very "I'll let someone else handle it" of it. π
π report_digit_event/2 β slide into the collector's DMs
report_digit_event(DigitMapEvalPid, Events) ->
ok | {error, Reason}
when
DigitMapEvalPid :: pid(),
Events ::
digit_map_event() |
[digit_map_event()],
Reason :: term().
Send one or more events to the event collector process. π©
Basically: send one or more events to a process that's evaluating a digit map β that is, a process that's executing megaco:eval_digit_map/1,2.
Careful bestie: the events$s|$S,l|Land$z|$Zhave nothing to do with the timers using those same characters. Don't get it twisted. π
π reset_stats/0, reset_stats/1 β the reset button
reset_stats() -> void().
Reset all the (SNMP) statistics counters. Boom, clean slate. β¨
reset_stats(GCounter) -> void() when GCounter :: global_counter();
(ConnHandle) -> void() when ConnHandle :: conn_handle().
Version one: reset the specified (SNMP) statistics counter.
Version two: reset all the (SNMP) statistics counters for a connection. π«Ά
β set_trace/1 β turn the dial on the trace level
set_trace(Level) -> void() when Level :: trace_level().
This function is used to change the megaco trace level. ποΈ
Fair warning: it assumes tracing has already been enabled (see enable_trace above, bestie). Don't come for me if you skipped that step. π
π start/0 β let's gooo
start() -> ok | {error, Reason} when Reason :: term().
Starts the Megaco application. iconic. π
so here's the vibe π
β you can either register users explicitly with megaco:start_user/2, and/or set them up statically by setting the application environment variable 'users' to a list of {UserMid, Config} tuples. either way, the deets live in megaco:start_user/2. go peek. π
start_user β first-time setup for ur user β¨
start_user(UserMid, Config) -> ok | {error, Reason}
when
UserMid :: mid(),
Config :: [{Item, Value}],
Item :: user_info_item(),
Value :: term(),
Reason :: term().
initial configuration of a user, aka the first glow-up. πΈ
needs the megaco application to be started first, no cap. a user is either a Media Gateway (MG) or a Media Gateway Controller (MGC), and listen β one Erlang node can host SO many users, she's versatile like that. π
a user is identified by its UserMid, which must be a legal Megaco MID. non-negotiable bestie.
Config is a list of {Item, Value} tuples. wanna know which items and values are actually valid? megaco:user_info/2 has you. π«Ά
stop β bye bye app π
stop() -> ok | {error, Reason}
when
Reason :: term().
stops the Megaco application. that's it. that's the whole function. iconic minimalism. π
stop_user β yeet a user's config π¦
stop_user(UserMid) -> ok | {error, Reason}
when
UserMid :: mid(),
Reason :: term().
deletes the configuration of a user. π
β οΈ requires that the user does not have any active connection. so close ur conns first, bestie, or it's gonna be a whole thing.
system_info β the tea on the system β
system_info(Item) -> Value
when
Item :: system_info_item(),
Value :: term().
lookup system information. yes queen, go get that info. π
test_digit_event β feeding the digit map collector π
test_digit_event(DigitMap, Events) ->
{ok, Kind, Letters} | {error, Reason}
when
DigitMap :: digit_map_value() | ParsedDigitMap,
ParsedDigitMap :: term(),
Events :: digit_map_event() | [digit_map_event()],
Kind :: digit_map_kind(),
Letters :: [digit_map_letter()],
Reason :: term().
feed the digit map collector with events and get the result back. π
this function starts the evaluation of a digit map with megaco:eval_digit_map/1 and then sends a sequence of events to it with megaco:report_digit_event/2 β all so that testing digit maps is, like, way less annoying. ur welcome. β¨
test_reply β is ur Reply actually composing correctly?? π
test_reply(ConnHandle, Version, EncodingMod, EncodingConfig,
Reply) ->
{MegaMsg, EncodeRes}
when
ConnHandle :: conn_handle(),
Version :: protocol_version(),
EncodingMod :: module(),
EncodingConfig :: list(),
Reply :: error_desc() | [action_reply()],
MegaMsg :: megaco_message(),
EncodeRes :: {ok, Bin} | {error, Reason},
Bin :: binary(),
Reason :: term().
tests if the Reply argument is correctly composed. π
this one is only intended for testing purposes, fr fr. it's supposed to test theactual_reply()return value of the callback functionshandle_trans_requestandhandle_trans_long_request(with the additions of theEncodingModandEncodingConfigarguments). it composes a complete megaco message and attempts to encode it. the return value will be a tuple of the composed megaco message and the encode result. π
test_request β same energy, but for Actions π
test_request(ConnHandle, Version, EncodingMod, EncodingConfig,
ActionRequests) ->
{MegaMsg, EncodeRes}
when
ConnHandle :: conn_handle(),
Version :: protocol_version(),
EncodingMod :: module(),
EncodingConfig :: list(),
ActionRequests :: action_reqs() | [action_reqs()],
MegaMsg :: megaco_message(),
EncodeRes :: {ok, Bin} | {error, Reason},
Bin :: binary(),
Reason :: term().
tests if the Actions argument is correctly composed. π
again β only intended for testing purposes. it's supposed to have a same kind of interface as thecall/3orcast/3functions (with the additions of theEncodingModandEncodingConfigarguments). it composes a complete megaco message and attempts to encode it. the return value will be a tuple of the composed megaco message and the encode result. β
token_tag2string β tag to string, slay π«
token_tag2string(Tag, EncodingMod, Version) -> Result
when
Tag :: atom(),
EncodingMod :: pretty | compact | module(),
Version :: protocol_version() | v1 | v2 | v3,
Result :: string() | {error, Reason},
Reason :: term().
convert a token tag to a string. β¨
- if no encoder module is given, the default is used (which is
pretty). π - if no or an unknown version is given, the best version is used (which is
v3). π - if no match is found for
Tag,Resultwill be the empty string ([]). π (yeah, empty. no drama, just[].)
update_conn_info β glow-up ur conn info π¦
update_conn_info(ConnHandle, Item, Value) -> ok | {error, Reason}
when
ConnHandle :: conn_handle(),
Item :: conn_info_item(),
Value :: term(),
Reason :: term().
update information about an active connection. π
requires that the connection is activated. and check out conn_info_item/0 to see which items and values are actually valid, bestie. π₯
update_user_info β glow-up ur user info πΈ
update_user_info(UserMid, Item, Value) -> ok | {error, Reason}
when
UserMid :: mid(),
Item :: user_info_item(),
Value :: term(),
Reason :: term().
update information about a user. π
requires that the user is started. no starting, no updating, simple as.
user_info β all the user tea π
user_info(UserMid, Input) -> Result
when
Input :: Requests | Replies | Item,
Requests :: requests,
Replies :: replies,
Item :: user_info_item(),
UserMid :: mid(),
Conn :: conn_handle(),
Result :: RequestsResult | RepliesResult | ItemResult,
RequestsResult :: [{Conn, [TransId]}],
ItemResult :: term(),
RepliesResult :: [{Conn, [{TransId, ReplyState, Handler}]}],
TransId :: transaction_id(),
ReplyState :: prepare | eval_request | waiting_for_ack | aborted,
Handler :: undefined | pid().
lookup user information. the main character of lookups, honestly. π
- lookup user info about currently active requests: expected input type
Input :: Requests, with expected output typeResult :: RequestsResult. π₯ - lookup user info about currently active replies: expected input type
Input :: Replies, with expected output typeResult :: RepliesResult. π
versions2 β utility info grabber π§
versions2() -> {ok, VersionInfo} | {error, Reason}
when
VersionInfo :: list(),
Reason :: term().
utility functions used to retrieve some system and application info. π
the difference between the two functions is in how they get the modules to check: versions1 uses the app-file, and versions2 uses the function application:get_key. iykyk. β
and that's a wrap bestie, no cap β this whole page came from Ericsson AB, and it's megaco 4.9.2 in the megaco(3) manual. u made it to the end, ur literally the main character rn ππβ¨
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms