com.innovaphone.working.client

The com.innovaphone.working.client api enables apps to start and stop the working time for a given user.

Summary

GetService
AppWebsocketClientConnectComplete
AppWebsocketClientMessage
Messages send to the service
Messages received by the service

GetService

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();

AppWebsocketClientConnectComplete

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();
}

AppWebsocketClientMessage

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
        ...
    }
    ...
}

Messages send to the service

StartWorkingTime
StopWorkingTime
GetStatus

Messages received by the service

StartWorkingTimeResult
StopWorkingTimeResult
GetStatusResult

StartWorkingTime

If not already started, it starts the working time of the user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

StartWorkingTimeResult

Answer to the start of the working time of an user.

Parameters

string result "ok" or "failed".

StopWorkingTime

If not already stopped, it stops the working time of the user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

StopWorkingTimeResult

Answer to the stop of the working time of an user.

Parameters

string result "ok" or "failed".

GetStatus

Check the status of the given user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

GetStatusResult

Answer to check the status of an user.

Parameters

string result "started" or "stopped".