Created
August 18, 2012 13:09
-
-
Save datafatmunger/3386775 to your computer and use it in GitHub Desktop.
This file contains 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
WebSocketStompMock = SockJS; | |
var guid = function() { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); | |
}(); | |
var stream = 'dev.ideedock.com'; | |
var stomp = Stomp.client('http://'+stream+':55674/stomp'); | |
stomp.connect('guest', 'guest', function(x) { | |
stomp.subscribe('/topic/'+guid, function(d) { | |
var data = JSON.parse(d.body); | |
if(data.user) { | |
//Signup or login complete! - Do something fun! | |
} else { | |
//Server knows you're here! - Login or signup! | |
} | |
}); | |
var message = JSON.stringify({ url: stream}); | |
stomp.send('/topic/'+guid, {}, message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment