Created
January 2, 2012 19:39
-
-
Save zclancy/1551834 to your computer and use it in GitHub Desktop.
Sametime presence utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Instant = {}; | |
// Function to detect Sametime Connect client presence | |
Instant.detectClient = function () { | |
if ( self.getstatus ) { | |
return true; | |
} else { | |
return false; | |
} | |
}; | |
// Start chat depending on presence | |
Instant.startChat = function (stid) { | |
// Check presence of user to determine how to start chat | |
if (Instant.detectPresenceOfUser(stid)) { | |
Instant.launchSametimeConversation(stid); // Sametime can see the user, start Sametime chat | |
} else { | |
Instant.launchWebConversation(stid); // Sametime can't see the user, start web client | |
} | |
}; | |
// Function to launch a conversation using Sametime Connect client. | |
// Pass in the user/queue to start a conversation with. | |
Instant.launchSametimeConversation = function (stid) { | |
var imgObj = new Image(); | |
imgObj.src = 'http://localhost:59449/stwebapi/chat/' + stid; | |
}; | |
// Start a conversation using the web client | |
// Pass in the user/queue to start a conversation with. | |
Instant.launchWebConversation = function (stid) { | |
// Web chat launch code would go here | |
}; | |
// Detect presence of watched Sametime users | |
Instant.detectPresenceOfUser = function (stid) { | |
user = stid.toLowerCase(); // Convert stid variable to lower case for switch statement | |
var liveNames = sametime_livenames; | |
var detected = false; | |
if (liveNames === null || liveNames === undefined) { | |
return detected; | |
} | |
else { | |
var i = 0; | |
for (i = 0; i < liveNames.length; i++) { | |
if (liveNames[i]._username.toLowerCase() == user) { | |
if (typeof liveNames[i]._properties == "undefined") { | |
detected = false; | |
} | |
else { | |
detected = true; | |
} | |
break; | |
} | |
} | |
return detected; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment