Re: Agenda SDK Dialog: How to send BatchCounterUpdates from the JS SDK
On the WebSocket connection, between the App Object and the App Service, a PbxSignal message with an presence_notify facility must be sent. It will be forwarded to the myApps client by the PBX, even if no App is running in the client.
Required Steps:
1) Enable App Service for presence Subscriptions
On a C++ App Service:
void ApplicationSession::AppWebsocketAppInfo(const char * app, class json_io & msg, word base)
{
msg.add_bool(base, "presence", true);
}
On JavaScript App Service:
It is not possible at the moment. I could be added in the config.json on later release.
The myApps cleint will get following indication, if presence is enabled for the App Service:
{
"mt":"UpdateAppsInfo",
"app":{
"name":"chat",
"title":"Chat",
"url":"../../APPS/chat/chat",
"inline":true,
"info":{
"apis":{
"com.innovaphone.chat":{
},
"com.innovaphone.notificationhandler":{
}
},
"wake":[
"chat"
],
"presence":true
}
2) Handle incoming presence_subscribe call on the App Service:
new PbxApi("PbxSignal").onconnected(function (conn) {
log("Badge: new connection with PbxSignal support");
connections.push(conn);
conn.send(JSON.stringify({"api": "PbxSignal", "mt": "Register", "flags": "NO_MEDIA_CALL"}));
conn.onmessage(function (msg) {
var obj = JSON.parse(msg);
log("Badge: rcv" + msg);
if (obj.mt == "RegisterResult") {
// handele RegisterResult
}
if (obj.mt == "Signaling") {
// handle incoming presence_subscribe call => callid required later for sending badge notifications
}
});
});
3) Send presence_notfy facility into subscription call:
function updateBadge(count,callid) {
var msg = { "api": "PbxSignal", "mt": "Signaling", "call": callid, "src": "badge", "sig": { "type": "facility", "fty": [{ "type": "presence_notify", "status": "open", "note": "#badge:" + count, "contact": "app:" }] } };
connections.filter(function (v) { return v.api === "PbxSignal"; })[0]
.send(JSON.stringify(msg));
}
In the attached diagram I have marked the path with pink color.
BadgeCount.png