Picture of HannesN
Registered 5 years 30 days
HannesN Friday, 11 September 2020, 10:18 AM
PHONE app as a template
Dear Innovaphone,

We need 2 things:

  1. I'm going to copy the message in just as it has been given to me in German, and then I give a translation
    • “dann bitte nochmal im forum fragen ob sie uns die PHONE App aus der Inovaphone AppPlattform als vorlage geben können... als parallel thread zu der Profil app”
      • And here the translation
    • “then please ask again in the forum whether they can give us the PHONE app from the Inovaphone app platform as a template ... as a parallel thread to the profile app”
  2. We then also need, somehow, access to the profile app as stipulated in another form post by me that hasn’t been assigned yet that lives@ http://forum.innovaphone.com/moodle2/mod/forum/discuss.php?d=25458
I’m looking forward to your reply,

Yours,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Tuesday, 15 September 2020, 11:24 AM
Re: PHONE app as a template
Hi Hannes,

the phone app is a pure javascript app which is located inside the PBX.
Feel free to take a look at the javascript sources by simply opening the phone app inside a browser and investigating the sourcecode in the browser development tools.

The profile app is a bit different. You have the javascript part available here too, but the c++ server side part not (we do not publish this code).
Basically the profile app uses the replicator of the SDK on the server side.

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Tuesday, 15 September 2020, 12:06 PM
Re: PHONE app as a template
Thanks Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 16 September 2020, 07:43 AM in response to Daniel Deterding (innovaphone)
Re: PHONE app as a template
Morning Daniel,

I have one more question that I think you can answer very quickly. I want to know if and/or how I can send a custom JSON message through the RCC api, or another api if needed. In short I want to send the time when calls started to app instances that have been opened after the call(s) has/have started.

Thanks,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 16 September 2020, 08:01 AM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Hi Hannes,

on your javascript side, you can send a message through your standard appwebsocket connection without any specific API. This is what the default template/example app already does, where "mt":"IncrementCount" is sent if you press the button.

There is a Task function IncrementCount::Complete where a StartUpdate is called which notifies all other sessions with the task *CountUpdate.

This is the app_updates functionality described here:
http://sdk.innovaphone.com/common/lib/app_updates.htm

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 16 September 2020, 08:12 AM
Re: PHONE app as a template
Thanks Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 16 September 2020, 10:59 AM in response to Daniel Deterding (innovaphone)
Re: PHONE app as a template
Hi Daniel,

Sorry I just can't get it working as you describe. I don't understand what mt to send to catch CountUpdate?

Thanks,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 16 September 2020, 12:16 PM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Hi Hannes,

Inside your javascript code you send app.send({"mt":"CallsStarted", "ts":new Date().getTime() });

You should receive this message inside your session on your C++ side in ...Session::AppWebsocketMessage

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 13 January 2021, 10:14 AM
Re: PHONE app as a template
Morning Daniel,

This is now really a long time before I respond on this message. Thanks for the suggestion, although I didn't really want to go this way, however I got a lot of pressure to get this app out.

So if I send my own message to the backend, how does a custom reply look like in Session::AppWebsocketMessage?

An example is:

char sb[1000];
char b[100];
char * tmp = b;
class json_io send(sb);
word base = send.add_object(0xffff, nullptr);
send.add_string(base, "mt", "MonitorCountResult");
if (this->currentSrc) send.add_string(base, "src", session->currentSrc);
send.add_ulong64(base, "count", this->instance->count, tmp);
this->SendResponse(send, sb);

this->instance->StartUpdate(new NewApp1BadgeCountUpdate(this->instance, sip, 0, 0, nullptr));

However I can't get it tweaked for my own custom message.

Thanks for your help.

Hannes
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 13 January 2021, 02:52 PM in response to Daniel Deterding (innovaphone)
Re: PHONE app as a template
Hi Daniel,

my boss introduced a new concept this morning, and that is if we can use the PostgreSQL databank. That will actually be great since he also want app settings to be saved over sessions.

In short, how can an app instance access the PostgreSQL databank with either new databank or with the one created with the creation of the instance?

Regards,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 13 January 2021, 03:02 PM
Re: PHONE app as a template
Hi Hannes,

for your previous question:
The App Update mechanism is described here:
http://sdk.innovaphone.com/common/lib/app_updates.htm

For databases: there is a tutorial and the template app already shows the usage of databases
Tutorial: http://sdk.innovaphone.com/doc/tutorials/DatabaseTutorial.htm

Configuration can be stored with the config implementation. This could be done within a PBX Manager Plugin or an Admin App:
http://sdk.innovaphone.com/common/lib/config.htm

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 13 January 2021, 03:11 PM
Re: PHONE app as a template
Thanks Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Tuesday, 19 January 2021, 11:06 AM in response to Daniel Deterding (innovaphone)
Re: PHONE app as a template

Hi Daniel,


This is really embarrassing for me, but I just can’t get my app to meaningfully send an arbitrary JSON message through the default connection (like you suggested). My problem is 2 fold and then I will tell you how I set it up:

  1. If I get it to send an arbitrary message, the app restarts the whole time and all variables are being deleted and the dom is completely populated over again,

  2. If I get it that the app doesn’t restart again and again, the JSON message doesn’t come through, although it has been sent, but nothing comes back. Both these points might not be related at all, and is rather what I suspect.

So this is how I set it up:

  1. In my JS file I put the SDK templet websocket connection back like follow:

var app = new innovaphone.appwebsocket.Connection(start.url, start.name);

app.checkBuild = true;

app.Xonconnected= app_connected;


function app_connected(domain, user, dn, appdomain) {

var src = new app.Src(update);

src.send({ mt: signal });

signal = "";



function update(msg) {

if (msg.mt != "") {

updateDoorTeam(msg.mt);

}

}

}


  1. In the myapp.cpp I extended the if… if else… else that my message will be caught by the else, since then I can use only the msg.mt to say everything I want. It looks like the following, which I know is sending more back than what I need.

if (currentSrc) free(currentSrc);

currentSrc = src ? _strdup(src) : nullptr;

if (!strcmp(mt, "MonitorCount")) {....

….

else {

char sb[1000];

char b[100];

char* tmp = b;

class json_io send(sb);

word base = send.add_object(0xffff, nullptr);

send.add_string(base, "mt", mt);

if (this->currentSrc) send.add_string(base, "src", this->currentSrc);

send.add_ulong64(base, "count", this->instance->count, tmp);

this->SendResponse(send, sb);


AppWebsocketMessageComplete();

}


I also send you a copy of my JS file that works without any problems, until I try to do something of the above.


Then you won’t believe it, but I also followed the Database tutorial to the T (exactly the same), with a new app, and I can’t get that working. However, that can wait for another day, except if I can get that working even


Thanks in advance,


Yours,


Hannes


2021-01-13_Code_save.txt
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 20 January 2021, 06:53 AM
Re: PHONE app as a template
Hi Hannes,

if your App restarts if you start sending own messages, it means that you have some bugs on the C++ server side and it crashes.

Do you debug through Visual Studio? In this case you may start debugging and the debugger should catch the crash and stop at the point where your app is crashing.

If not, you can open your AP Manager and download the backtrace file of your app, which should contain the callstack and maybe some hint, why it is crashing.
You can also add some debug->printf traces at some points in your C++ code to see which code points are reached and which not:

debug->printf("until here it's fine");

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Monday, 1 February 2021, 08:03 AM
Re: PHONE app as a template

Good morning Daniel,


Thanks for your answer, but something more is wrong. What I did is I made a complete new installation of everything (pbx, app platform, Visual Studio and SDK). Then I created only a NewApp1 with absolutely nothing but only what the SDK compiled, and then launched this app which is 100% only template. This app crashes the whole time as well, just as in my app with the websocket

var app = new innovaphone.appwebsocket.Connection(start.url, start.name);

app.checkBuild = true;

app.Xonconnected= app_connected;


Here is a screenshot of my instance in a browser and the console showing the restart the whole time:



I guess if it doesn't work in a clean brand new template, I should not be surprised if it doesn't work in my own app.


I would highly appreciate your help, since this app is long overdue.


Hannes

Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Monday, 1 February 2021, 08:12 AM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Hi Hannes,

your App doesn't crash but the login doesn't match (you see a "mt":"AppLoginResult" without an "ok":true => password missmatch).
You have the PBX App object inside your PBX with a certain password and you have the app instance of your app inside the AP Manager.

The password from this instance doesn't match the password configured inside the PBX App object.

You can now manually configure the same password on both sides (without using the PBX Manager plugin of the app) or you use the PBX Manager Plugin of the app, but in this case, you won't know the instance password, as a random one is used here, so if you then debug your app through Visual Studio, it doesn't work.

Inside your app-main.cpp file in the root folder of your app, the instance password is set to pwd:
instanceArgs.appPassword = "pwd";

So I would configure this password inside the PBX App object of your app too if you want to debug with Visual Studio, as while debugging, not the app instance config of the AP Manager is used, but the instance config of your main.cpp file.

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 3 February 2021, 08:31 AM
Re: PHONE app as a template
Morning Daniel,

thanks for your previous answer.

What I did is I have reduced my app to the bear minimum to where it crashes with the 2 appwebsockets. With only 1 or the other it doesn't crash.

Maybe your educated look can immediately give me a reason.

Here is the code:



/// <reference path="../../sdk/web1/lib1/innovaphone.lib1.js" />
/// <reference path="../../sdk/web1/appwebsocket/innovaphone.appwebsocket.Connection.js" />
/// <reference path="../../sdk/web1/ui1.lib/innovaphone.ui1.lib.js" />

var Shift = Shift || {};
Shift.Queue_Monitor = Shift.Queue_Monitor || function (start, args) {
this.createNode("body");
var that = this;
 
var app = new innovaphone.appwebsocket.Connection(start.url, start.name);
app.checkBuild = true;
 
var rcc = null;

//Consume the Client API to receive the PBX URL
//var clientApi = start.consumeApi("com.innovaphone.client");
window.addEventListener("message", onpostmessage);
//this.clientAPI = clientApi;

window.addEventListener("message", onpostmessage);

function onpostmessage(e) {
if (e.data) {
var obj = JSON.parse(e.data);
if (obj.mt == "ApiUpdate" && !rcc) {
var url = obj.apis["com.innovaphone.client"]["@client"]["url"];
if (url) {
url = "ws" + url.slice(4, url.search("/APPCLIENT/")) + "/APPS/websocket";

//Set an AppWebsocket connection to the PBX
rcc = new innovaphone.appwebsocket.Connection(url, start.name, null, null, rcc_connected, rcc_message);

}
}
}
}
 
//This function is called when the AppWebsocket connection is set:
function rcc_connected(d, user, dn, appdomain) {
//The first message that you need to send is UserInitialize with the CN of the user you want to monitorize (in this case the login user)
rcc.send({ "mt": "Initialize", "api": "RCC", "calls": true });
}

//This function will be called every time a RCC JSON is received
//With every JSON you send, a Result message should be received
function rcc_message(msg) {
 
console.log(msg);
 
}
}
Shift.Queue_Monitor.prototype = innovaphone.ui1.nodePrototype;

I also attach the console log.

Thanks for all your help.

Hannes
Selection_048.png

Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 3 February 2021, 10:34 AM in response to Daniel Deterding (innovaphone)
Re: PHONE app as a template
Hi again Daniel,

I forgot to add that each of the 2 appwebsocks alone work perfectly (no password issues) and with the 1st I can send my own arbitrary message, but as soon as both need to be initialiced together then the app crashes.

I just want to know if there is something I'm missing with the initialication process in JavaScript.

Regards,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 3 February 2021, 01:14 PM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Hi Hannes,

13r1 contains a limitation that you can just have one appwebsocket connection per iframe inside myApps.
This is changed in the forthcoming 13r2 release.

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Wednesday, 3 February 2021, 01:45 PM
Re: PHONE app as a template
Thanks so much Daniel, this is great news because that means then I can do my own thing sending JSONs between instances with the second appwebsocket.

Is there something I should know implementing it in the new release, or will the way work I had it in this own iframe?

Have a great day.

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 3 February 2021, 01:51 PM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Your way should work as far as I understood it myself ;)

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Tuesday, 2 March 2021, 03:03 PM
Re: PHONE app as a template
Hi Daniel,

I forgot to ask when the version 13r2 is coming out, thus the release date?

Thank you.

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Tuesday, 2 March 2021, 03:07 PM
1 of 1 users consider this post helpful
Re: PHONE app as a template
Hi Hannes,

there is no official release date.
We hope to release a beta within the next weeks.

Greetings,
Daniel
Picture of HannesN
Registered 5 years 30 days
HannesN Tuesday, 2 March 2021, 03:10 PM
Re: PHONE app as a template
Thanks
← You can define your color theme preference here