var oSessionIM = new tsip_session_message(oSipStack,
tsip_session.prototype.SetToStr("
2233422677"), // the destination number
tsip_session.prototype.SetHeader("What", "IM") // not required
);
// listen for messaging events
oSipStack.on_event_message = function (evt) {
console.debug(evt.s_phrase);
switch (evt.e_message_type) {
case tsip_event_message_type_e.I_MESSAGE: // Incoming message
{
evt.get_session().accept(); // send SIP 200 OK
console.debug("Incoming message=%s", evt.get_message().get_content_as_string());
break;
}
case tsip_event_message_type_e.AO_MESSAGE: // Answer to Outgoing message
{
if (evt.i_code >= 200 && evt.i_code <= 299) {
console.debug("sent");
}
else if (evt.i_code >= 300) {
console.debug("not sent (%d)", evt.i_code);
}
break;
}
}
};
// send the Instant Message (SIP MESSAGE request)
oSessionIM.send(
new String("P�che � la moule"), // content
"text/plain; charset=utf8" // content type
);
> --
>
>