The com.innovaphone.working.client api enables apps to start and stop the working time for a given user.
The app service finds and connects to the right Service API:
class IService* service = NULL;
class AppSession* session = NULL;
for (auto pbxsession : app->pbxSessions) { //Look for the right app service
if (pbxsession->services) {
service = pbxsession->services->GetService("com.innovaphone.working.client");
session = pbxsession;
if (service) break;
}
}
//If found then connect the appwebsocket client
if (service) this->awsClient->Connect(service->GetWebsocketUrl(), service->GetName(), session->services->CreateAuthenticator(), false);
else this->awsClient->Close();
Callback when the appwebsocket client has been connected, so you can start sending messages.
void App::AppWebsocketClientConnectComplete(class IAppWebsocketClient* appWebsocketClient)
{
char sb[200];
class json_io send(sb);
word base = send.add_object(JSON_ID_ROOT, 0);
send.add_string(base, "mt", "StopWorkingTime");
send.add_string(base, "sip", "test_user");
send.add_string(base, "api", "--innovaphone-client-working-api");
this->awsClient->MessageSend(send, sb);
this->awsClient->MessageComplete();
}
Function where the answers from the Working Client API are received.
void App::AppWebsocketClientMessage(class IAppWebsocketClient* appWebsocketClient, class json_io& msg, word base, const char* mt, const char* src)
{
if (!strcmp(mt, "StopWorkingTimeResult")) { //Manage the answers from the Working Client API
...
}
...
}
If not already started, it starts the working time of the user.
string sip | The SIP of the user. |
string api | "--innovaphone-client-working-api" |
Answer to the start of the working time of an user.
string result | "ok" or "failed". |
If not already stopped, it stops the working time of the user.
string sip | The SIP of the user. |
string api | "--innovaphone-client-working-api" |
Answer to the stop of the working time of an user.
string result | "ok" or "failed". |
Check the status of the given user.
string sip | The SIP of the user. |
string api | "--innovaphone-client-working-api" |
Answer to check the status of an user.
string result | "started" or "stopped". |