exampple v0.7.1 Exampple.Router

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

Link to this macro

chat(xmlns \\ "", controller, function)

(macro)
Link to this macro

discovery(block \\ nil)

(macro)
Link to this macro

envelope(xmlns)

(macro)

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.

Link to this macro

error(xmlns \\ "", controller, function)

(macro)
Link to this macro

fallback(controller, function)

(macro)
Link to this macro

feature(namespace)

(macro)
Link to this macro

get(xmlns, controller, function)

(macro)
Link to this macro

groupchat(xmlns \\ "", controller, function)

(macro)
Link to this macro

headline(xmlns \\ "", controller, function)

(macro)
Link to this macro

identity(opts)

(macro)
Link to this macro

includes(module)

(macro)

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.

Link to this macro

iq(xmlns_partial \\ "", list)

(macro)

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.

Link to this macro

join_with(separator)

(macro)

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.

Link to this macro

message(xmlns_partial \\ "", list)

(macro)

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.

Link to this macro

normal(xmlns \\ "", controller, function)

(macro)
Link to this function

ns_join(chunks, separator)

Link to this macro

presence(xmlns_partial \\ "", list)

(macro)

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.

Link to this macro

probe(xmlns \\ "", controller, function)

(macro)
Link to this function

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.

Link to this macro

set(xmlns, controller, function)

(macro)
Link to this macro

subscribe(xmlns \\ "", controller, function)

(macro)
Link to this macro

subscribed(xmlns \\ "", controller, function)

(macro)
Link to this macro

unavailable(xmlns \\ "", controller, function)

(macro)
Link to this macro

unsubscribe(xmlns \\ "", controller, function)

(macro)
Link to this macro

unsubscribed(xmlns \\ "", controller, function)

(macro)