Integrate Microsoft Communicator in web application

I have recently integrated Microsoft Communicator in one of the web based project. Initially it sounds a bit complicated but here is it :

Add reference to following assembly

using CommunicatorAPI;
using CommunicatorPrivate;
using System.Runtime.InteropServices;
// object initialization  MyCommunicator comm = new MyCommunicator();          Response.Write(string.Format("Your status :{0}",comm.GetCommStatus()));
Options 2
add below Js code in your web page and call functions wherever you want 
function ShowUserName(cntrlname,cntrlvalue) {alert(cntrlname);
}
function togglePannelStatus(content) {     var expand = (content.style.display == "none");     content.style.display = (expand ? "block" : "none");     var chevron = content.parentNode             .firstChild.childNodes[0].childNodes[0];     chevron.src = chevron.src             .split(expand ? "expand.gif" : "collapse.gif")             .join(expand ? "collapse.gif" : "expand.gif");
}
 
//show communicator status 
var ns4 = (navigator.appName.indexOf("Netscape") >= 0           && parseFloat(navigator.appVersion) >= 4           && parseFloat(navigator.appVersion) < 5) ? true : false;
var ns6 = (parseFloat(navigator.appVersion) >= 5           && navigator.appName.indexOf("Netscape") >= 0) ? true : false;
var ns = (document.layers) ? true : false;
var ie = (document.all) ? true : false;
function getElLeft(el) {     if (ns4) { return el.pageX; }     else {         xPos = el.offsetLeft;         tempEl = el.offsetParent;         while (tempEl != null) {             xPos += tempEl.offsetLeft;             tempEl = tempEl.offsetParent;         }         return xPos;     }
}
function getElTop(el) {     if (ns4) { return el.pageY; }     else {         yPos = el.offsetTop;         tempEl = el.offsetParent;         while (tempEl != null) {             yPos += tempEl.offsetTop;             tempEl = tempEl.offsetParent;         }         return yPos;     }
}
var sipUri //= "emailaddress
var nameCtrl;
function ShowOOUI(sipURI, obj) {     nameCtrl = new ActiveXObject('Name.NameCtrl.1');     if (nameCtrl.PresenceEnabled) {         nameCtrl.OnStatusChange = onStatusChange;         nameCtrl.GetStatus(sipURI, "1");     }     var oouiX = getElLeft(obj); oouiY = getElTop(obj);     nameCtrl.ShowOOUI(sipURI, 0, oouiX, oouiY);
}
function HideOOUI() { nameCtrl.HideOOUI(); }
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); 
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s