Librairie javascript TSLib
TSLib est une librairie javascript, bâtie sur le protocole TelServices, qui vous permet de superviser votre poste téléphonique depuis une page web.
- Liaison avec TelServer avec gestion de la redondance du lien
- API de haut niveau (masquant l'encodage du protocole TelServices)
Insertion dans la page web
<head>
<script type="text/javascript" src="/TSLib/TSLib-bundle.js"></script>
<script type="text/javascript" src="/TSLib/TSLib-config.js"></script>
</head>
Configuration
Elle se limite à fournir l'adresse de TelServer dans le fichier "TSLib-config.js".
unigone_config = {
TELSERVICES_TELSERVER_URL: "http://telserver.mycompany.com:8082"
};
Si TelServer est redondé, une deuxième adresse peut être définie.
Supervision d'un poste téléphonique
Elle s'effectue au travers d'un objet appelé "context" :
var context = unigone.TSLib.context.getContext();
Supervision du poste "801" :
context.activateService("openSession", {
deviceNumber: "801"
});
Appels
Déclenchement d'un appel vers le poste "802" :
context.activateService("makeCall", {
calledPartyNumber: "802"
});
Réponse à un appel :
context.activateService("answerCall");
Gestion de l'état agent
context.activateService("agentState", {
state: "ready"
});
Réception des événements
Evénements à base appels :
context.addListener({
originatedCall: function(simpleCallEvent) { console.log('outgoing call to: '+simpleCallEvent.otherParty.number) },
incomingCall: function(simpleCallEvent) { console.log('incoming call from: '+simpleCallEvent.otherParty.number); },
clearedCall: function(simpleCallEvent) { console.log('end of call with: '+simpleCallEvent.otherParty.number) }
});
Evénements à base session :
context.addListener({
sessionChange: function(sessionEvent) { console.log('admin state: '+sessionEvent.state+';operational state: '+sessionEvent.operational); }
});