Kunal Kerkar bio photo

Kunal Kerkar

I throw caution to the wind, dance terribly, live in Vacouver, believe in cynical kinda love and spend time watching the moonlit sky!

Twitter Github Stackoverflow

About stanzas' and origins' (Prosody)

11 Jun 2011 - Manipal

Here is a structure of the stanza property of an event,

stanza =  {name = "message";  
attr = {  from = "...";  to = "..."; };  };

A basic event I’m using to test my script has a stanza and a origin property. The origin property looks like this.

origin =  { ip = "...";  
    send = function(stanza) 
    print(stanza) 
    end;  
};

We must now define the stanza property, doing it manually would require you to set the metatables manually too. So heres an easy way of doing it. Use the stanza util module.

st = require "util.stanza";
event.stanza = st.stanza("message", {
    from="robot@abuser.com/zombie", 
    to="innocent@victim.com"
});