2010-11-09 8 views

risposta

7

Se si sta prendendo di mira la piattaforma Windows, il modo più semplice è quello di fare tutto sul lato client. Fintanto che i client eseguono IE, Office 2003 o versioni successive e Communicator 2007 o versioni successive, è possibile utilizzare l'oggetto ActiveX NameCtrl che viene distribuito con Office.

Il seguente codice dovrebbe iniziare:

<script> 

var sipUri = "[email protected]"; 

var nameCtrl = new ActiveXObject('Name.NameCtrl.1'); 
if (nameCtrl.PresenceEnabled) 
{ 
    nameCtrl.OnStatusChange = onStatusChange; 
    nameCtrl.GetStatus(sipUri, "1"); 
} 


function onStatusChange(name, status, id) 
{ 
    // This function is fired when the contacts presence status changes. 
    // In a real world solution, you would want to update an image to reflect the users presence 
    alert(name + ", " + status + ", " + id); 
} 

function ShowOOUI() 
{ 
    nameCtrl.ShowOOUI(sipUri, 0, 15, 15); 
} 

function HideOOUI() 
{ 
    nameCtrl.HideOOUI(); 
} 

</script> 

<span onmouseover="ShowOOUI()" onmouseout="HideOOUI()" style="border-style:solid">Your Contact</span> 

Per una soluzione mondo reale, si sarebbe solo bisogno di implementare un'immagine che cambia a seconda dello stato presenza che viene restituito (cioè una bolla presenza di visualizza accanto al nome di ciascun utente) e una raccolta di sip uris alle immagini, per garantire che sia possibile mappare una modifica dello stato in entrata all'immagine pertinente.

Problemi correlati