2

I am working on a website build using ASP.NET and C# for my company's intranet.So is it possible to integrate the Microsoft Office Communicator 2007 in ASP.NET Page. i.e. the site should be able to provide the current status(avalible, busy , offline) of all contacts and when a user clicks on the username, the chat window should open.

Kara
  • 6,115
  • 16
  • 50
  • 57
Aditya Singh
  • 9,512
  • 5
  • 32
  • 55

1 Answers1

5

Assuming the client machine is running Communicator, Office and IE, by far the simplest way is to use the NameCtrl in client-side script - the example below should gives the basic concepts. This will also give you the most bang-for-buck in terms of functionality. Hover over the "Your Contact" text to see the persona menu pop up.

For a real world solution, you'd just need to implement an image that changes depending on the presence state that gets returned (i.e. a presence bubble to display alongside each users name), and a collection of sip uris to images, to ensure you can map an incoming status change to the relevant image.

It's worth bearing in mind that the Ajax/CWA solution mentioned in the other answer will most likely not work with Lync Server (I believe Communicator Web Access is no more) so you'd need to change the solution if your company upgrades to Lync. I've tested the solution below, and it works with the Lync Server RC.

<script>

var sipUri = "your.contact@your.domain.com";

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>
Paul Nearney
  • 6,965
  • 2
  • 30
  • 37
  • @Paul Nearney Hi, Great solution. But i have a problem here. if i want to display all users in a table and their status, is it possible through javascript ? Here in this example it is showing for a single user. i want to show all users. Is it possible through javascript ? – Chandan Kumar Dec 24 '13 at 03:14
  • Yes, The second parameter in GetStatus is an ID. If you ensure this is unique for each user that you register via GetStatus, it will be passed back to you as the ID parameter in OnStatusChange. You could use this to e.g. look up the relevant user in an array, or to find the div that corresponds to the user who's status has just changed – Paul Nearney Jan 02 '14 at 10:04