megaco_transport(3erl)
π megaco_transport β the Megaco transport behaviour, bestie edition
okay so this is megaco_transport, an Erlang module, and it's basically the vibe check for anyone who wants to be a transport for Megaco. it's a behaviour, meaning you write the callback module and it has to bring these functions, no cap. iykyk π«Ά
β¨ DESCRIPTION β¨
so here's the tea: your callback module needs to export these functions. this is the whole roster:
send_message/2β mandatory (like, you literally cannot skip this one π)send_message/3β optionalresend_message/2β optional- (and there's a fourth bullet in the original list that's justβ¦ empty. a mystery. a ghost. we respect it π)
π EXPORTS π
π send_message/2 and send_message/3 β the main characters
Module:send_message(Handle, Msg) -> ok | {cancel, Reason} | Error
Module:send_message(Handle, Msg, Resend) -> ok | {cancel, Reason} | Error
the types, exactly as written:
Handle = term()
Msg = binary() | iolist()
Resend = boolean()
Reason = term()
Error = term()
so like. this is the "send a megaco message" function. that's the job. π€
now here's the interesting part β if it returns {cancel, Reason}, that means the transport module decided not to send the message. and listen, this is not an error, okay? no error messages get issued, no error counters get incremented, nothing is on fire. it's a whole intentional choice. what actually happens next depends on what kind of message was going out. π₯
for requests β megaco will cancel the message, super similar to how it'd behave if megaco:cancel had been called (after a successful send). the info gets propagated back to the user, but the route it takes depends on how the request was issued:
- requests issued with
megaco:callβ the info comes back to you in the return value β¨ - requests issued with
megaco:castβ the info arrives via a call to the callback functionhandle_trans_replyπ
for a reply β megaco will cancel the reply, and word of that gets returned to the user via a call to the callback function handle_trans_ack. simple as that π
btw, send_message/3 only gets called if the resend_indication config option has been set to the value flag. and the third argument, Resend, tells you whether this message send is a resend or not. that's it, that's the whole thing.
π¦ resend_message/2 β the re-run, the encore
Module:resend_message(Handle, Msg) -> ok | {cancel, Reason} | Error
types:
Handle = term()
Msg = binary() | iolist()
Reason = term()
Error = term()
this one re-sends a megaco message. π«
real talk though: this function only gets called if the user has set theresend_indicationconfig option totrueand it's actually a message resend. if both of those conditions aren't met,send_messagegets called instead. both boxes gotta be checked, no exceptions π―
and same energy as before β if it returns {cancel, Reason}, the transport module decided not to send it. not an error. no error messages, no counter increments, none of that. the consequences depend on the message type:
for requests β megaco cancels the message, basically just like megaco:cancel had been called (after a successful send). the info heads back to the user depending on how the request was issued:
megaco:callβ info delivered in the return value π«Άmegaco:castβ info delivered via a call to the callback functionhandle_trans_reply
for a reply β megaco cancels the reply, and that info goes back to the user via a call to the callback function handle_trans_ack. periodt. π
and that's the page, bestie β go forth and transport responsibly πΈ
with love from Ericsson AB, megaco 4.4.3, dated the very day this manpage was born β mwah π
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms