Picture of iqbal
Registered 5 years 221 days
iqbal Monday, 7 February 2022, 03:24 PM
How to use IPbxAdminApi with MonitorConfig.
Hi
I am trying to use IPbxAdminApi along with MonitorConfig classes.
if i send pbxAdminApi->SendGetObject("user1");
no callback funktion is called in MonitorConfig subclass.

can you please add some example code regarding this issue to documentation.
i also want to mention here that documentation is not upto date.

Regards
Iqbal

Here is my Implementation:
//APP constructor:
 RegisterJsonApi(this); this->monitorConfig = new MonitorApiConfig(this);
 pbxAdminApi = IPbxAdminApi::Create("byon-int-v13.de", "developer_v13");
 RegisterJsonApi(pbxAdminApi);
 pbxAdminApi->MonitorConfig(monitorConfig);
 pbxAdminApi->SendGetConfigObjects();
 pbxAdminApi->SendGetObject("user1"); InitReplicator(); Log("App instance started");
//MonitorConfig implementation
MonitorApiConfig::MonitorApiConfig(LineSelector* instance):UPbxMonitorConfig()
{this->instance = instance;} MonitorApiConfig::~MonitorApiConfig() {} void MonitorApiConfig::PbxConfigUpdate(const char* domain, const char* pbx, const char* dns)
{LOG_INSTANCE("MonitorApiConfig::PbxConfigUpdate called");}
void MonitorApiConfig::PbxConfigObjects(json_io& msg, word base, const char* mt, const char* src)
{ LOG_INSTANCE("MonitorApiConfig::PbxConfigObjects called");}
void MonitorApiConfig::PbxObject(json_io& msg, word base, const char* mt, const char* src)
{LOG_INSTANCE("MonitorApiConfig::PbxObject called");}
void MonitorApiConfig::PbxUpdateObject(json_io& msg, word base, const char* mt, const char* src)
{LOG_INSTANCE("MonitorApiConfig::PbxUpdateObject called");}
void MonitorApiConfig::PbxNodes(json_io& msg, word base, const char* mt, const char* src)
{LOG_INSTANCE("MonitorApiConfig::PbxNodes called");}
void MonitorApiConfig::PbxStun(json_io& msg, word base, const char* mt, const char* src)
{LOG_INSTANCE("MonitorApiConfig::PbxStun called");}
void MonitorApiConfig::PbxBooleans(json_io& msg, word base, const char* mt, const char* src)
{LOG_INSTANCE("MonitorConfig::PbxConfigUpdate called");}







//Logs: 02-07 14:12:18.732 line_selector@byon-int-v13.de PostgreSQLDatabase(00814af0,00814098)::DatabaseShutdown reason: DB_OK 02-07 14:12:18.732 AppService::AppStopped line_selector@byon-int-v13.de 02-07 14:12:18.738 AppService::Shutdown 02-07 14:12:18.760 AppService::AppService 13B317 02-07 14:12:18.770 AppService::AppStart line_selector@byon-int-v13.de 02-07 14:12:18.775 PbxAdminApi(byon-int-v13.de@developer_v13) 02-07 14:12:18.775 PbxAdminApi::MonitorConfig 02-07 14:12:18.775 line_selector@byon-int-v13.de App instance started 02-07 14:12:18.775 line_selector@byon-int-v13.de SoftPhone2::ServerCertificateUpdate cert:0 certLen:0 02-07 14:12:18.779 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c78098)::DatabaseConnectComplete 02-07 14:12:18.779 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c78098)::Connected connected:1 02-07 14:12:18.779 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c78098)::ExecSQLV user:01c825c8 flags:00000001 sqlCmd:CREATE TABLE IF NOT EXISTS "tblusers" (); 02-07 14:12:18.780 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c825c8)::DatabaseExecSQLResult dataset: 01c86460 02-07 14:12:18.780 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c78098)::ExecSQLV user:01c825c8 flags:00000001 sqlCmd:SELECT column_name FROM information_schema.columns WHERE table_name='tblusers'; 02-07 14:12:18.791 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c825c8)::DatabaseExecSQLResult dataset: 01c86420 02-07 14:12:18.791 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c78098)::ExecSQLV user:01c825c8 flags:00000001 sqlCmd:SELECT constraint_name FROM information_schema.table_constraints WHERE table_name='tblusers' 02-07 14:12:18.794 line_selector@byon-int-v13.de PostgreSQLDatabase(01c78af0,01c825c8)::DatabaseExecSQLResult dataset: 01c86460
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 7 February 2022, 06:16 PM
Re: How to use IPbxAdminApi with MonitorConfig.
Hello Iqbal,

I can not see any WebSocket messages in the Log. If you are working with the PBX WebSockt API make sure you have enabled App Logging on the App instance, so you can see the WebSocket messages between PBX and your service.

Usually, if you start the App Service from Visual Studio, App Log Flag is enabled automatically. If you start the App Service instance from the AP Manager, make sure to set the App Log option under Diagnostics of the App Instance.


I would check following:
  • App Object for the App Service has WebSocket and AdminApi enabled
  • WebSocket from the PBX is established towards App Service (you see PbxInfo message with "apis":["PbxApi",...])
  • GetObject message is sent to the PBX and is answered by the PBX with GetObjectResult

If this everything is OK, I would start digging into the usage of the AdminApi Interface by your App Service.

Best Regards
Andreas Fink
Picture of iqbal
Registered 5 years 221 days
iqbal Tuesday, 8 February 2022, 04:12 PM
Re: How to use IPbxAdminApi with MonitorConfig.
Hi Andreas

I had to add following to appwebsocket session class and then it worked.
maybe it would be helpfull for other people if you update documentation.
class JsonApi* jsonAdminApi = dynamic_cast<class JsonApiContext*>(instance)->CreateJsonApi("PbxAdminApi", this, msg, base);

Regards
Iqbal


if (!strcmp(mt, "PbxInfo")) {
 if (!strcmp(app, "XXXX"))
 {
 const char* pbx = msg.get_string(base, "pbx");
 const char* domain = msg.get_string(base, "domain");
 PBXManager::get()->setPbx(domain, "localhost");

 // start pbx admin session
 instance->StartPbxSession(domain, pbx);
 class JsonApi* jsonAdminApi = dynamic_cast<class JsonApiContext*>(instance)->CreateJsonApi("PbxAdminApi", this, msg, base);
 if (jsonAdminApi)
 {
 jsonAdminApi->JsonApiStart();
 }
 instance->StartUpdate(domain, pbx);
 class JsonApi* jsonApi = dynamic_cast<class JsonApiContext*>(instance)->CreateJsonApi("PbxTableUsers", this, msg, base);
 if (jsonApi)
 {
 jsonApi->JsonApiStart();
 }
 }
 }
← You can define your color theme preference here