wrtc.onSIPPresence() is an event function called when the presence status of a person you are subscribing to is changed.
You can use this event to update user's status on screen.
A SIP presence update has been received from SIP presence server.
wrtc.onSIPPresence(arg)
The contents of the JSON structure can differ depending on the type of information received:
Usually the received presence information has the following format:
{type:"sip_presence_notify", from:…, basic:…, activity:…, note:…, format:"application/pidf+xml", subscription_state:…, msg:…}
Usually you do not need to examine all arguments to be able to display correct presence information. Basic "available yes/no" information is given in arg.available. More detailed information can be found in arg.activity and arg.note. There is rarely need to examine the other arguments.
If you have subscribed to your own status you do not get the above response, but a list of who are subscribing to your presence status:
{type:"sip_presence_notify", from:…, format:"application/watcherinfo+xml", msg:…}
You need to parse the raw SIP message yourself to extract the list of persons subscribing to your presence status.
If you have called wrtc.setSIPSubscribe() or wrtc.setSIPPresence() but an error has occurred the argument JSON structure will contain:
{type:…, from:…, error:…, msg:…}
Ignored.
{type:"sip_presence_notify", fromAdress:"john.doe@company.com", available:true, note:"Available", format:"application/pidf+xml", subscription_state:"active;expires=296", msg:"<?xml version='1.0' encoding='UTF-8'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' xmlns:lt='urn:ietf:params:xml:ns:location-type' entity='sip:john.doe@company.com'><tuple id='t1120a64d'><status><basic>open<\/basic><\/status><\/tuple><dm:person id='pa920ee13'><dm:note>Available<\/dm:note><\/dm:person><\/presence>"}
wrtc.onSIPPresence = function(arg) {
if (arg.error)
window.alert(arg.fromAdress + ": error " + arg.error + ": " + arg.msg);
else if (arg.format == "application/watcherinfo+xml")
-- update list of persons subscribing to your presence --
else
-- update list of presence with arg.activity and arg.note --
}