Exampple.Router (exampple v0.10.6)
Router implements the dynamic to define the flow where a stanza will be following for find the controller and function where it should be attended.
Inside of this module are defined all of the macros we can use for the creation of our router template.
You can see in the general documentation information about the router.
Link to this section Summary
Functions
The envelopes are very usual in components and mainly if we are using the delegation specification (XEP-0355). You can see more information regarding this in the general documentation about routing.
Did you split your code in different applications but still want to keep
only one point to connect to the XMPP server? It's possible if you define
different routers and then, for the main one, you use includes/1
. This
macro is accepting a module containing the routes to be included.
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the iq
stanza type.
Use this whenever you want to change the way a namespace will be join. For some configurations like this one
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the message
stanza type.
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the presence
stanza type.
Run from the component for each incoming stanza to ensuring where it
should go based on the routing module we have compiled. Our routing
module should be available through the application configuration and
that's because we are sending the otp_app
here.
Link to this section Functions
The envelopes are very usual in components and mainly if we are using the delegation specification (XEP-0355). You can see more information regarding this in the general documentation about routing.
Did you split your code in different applications but still want to keep
only one point to connect to the XMPP server? It's possible if you define
different routers and then, for the main one, you use includes/1
. This
macro is accepting a module containing the routes to be included.
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the iq
stanza type.
Use this whenever you want to change the way a namespace will be join. For some configurations like this one:
iq "http://jabber.org/protocol" do
join_with "/"
get "disco#info", MyController, :disco_info_get
end
The namespace is join in this case using the slash (/) because we defined it previously to define the first route.
The default value for join is :
so for each example like which I put above
you have to use join_with
and it's restarted for each block.
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the message
stanza type.
ns_join(chunks, separator)
Specify a route block where we can add the different routes. This could
have the base namespace or not. This is based on the presence
stanza type.
route(xmlel, domain, otp_app, timeout \\ 5000)
Run from the component for each incoming stanza to ensuring where it
should go based on the routing module we have compiled. Our routing
module should be available through the application configuration and
that's because we are sending the otp_app
here.
The first parameter provided (xmlel
) is the stanza in
Exampple.Xml.Xmlel
format. The second parameter is the XMPP domain
for the component inside of the XMPP network. The last parameter is
optional, timeout
specified in milliseconds specify how much time
have the stanza to be processed, by default it's 5 seconds.
See the general documentation to know more about the routing process.