Skip to content

Instantly share code, notes, and snippets.

@rcurlette
Created July 10, 2013 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcurlette/5963709 to your computer and use it in GitHub Desktop.
Save rcurlette/5963709 to your computer and use it in GitHub Desktop.
Tridion GUI Extension js file to send messages from SignalR to the MessageCenter. Part of the SignalR + Tridion MessageCenter notification.
var $j = jQuery.noConflict();
var userid = GetUserID();
var connection = $j.connection('http://localhost:8123/channel');
connection.start()
.done(function() {
connection.send('join ' + userid);
connection.received(function (data) {
// Show MessageCenter Message
$messages.registerNotification(data);
console.log('message received, ' + userid + ':' + data);
});
})
.fail(function() {
console.log('error connecting to signalr');
});
function GetUserID() {
var id = Tridion.UI.UserSettings.getJsonUserSettings(true).User["@ID"];
var pos = id.indexOf('-');
id = id.substr(pos + 1);
pos = id.indexOf('-');
id = id.substr(0, pos);
return id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment