PageRenderTime 11ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 1ms

/wwwroot/demo/js/demo.js

http://github.com/AF83/ucengine
JavaScript | 40 lines | 34 code | 6 blank | 0 comment | 0 complexity | 004be741a24e7351db10d055b08cc77e MD5 | raw file
  1. (function($) {
  2. $(document).ready(onReady);
  3. function createAccount(client, uid) {
  4. return function(next) {
  5. client.user.register(uid, "none", "", {}, function(err, result) {
  6. next();
  7. });
  8. };
  9. }
  10. function authUser(client, uid) {
  11. return function(next) {
  12. client.auth(uid, "", function(err, result) {
  13. client.attachPresence(result);
  14. next();
  15. });
  16. };
  17. }
  18. function startLive(client) {
  19. return function() {
  20. var meeting = client.meeting("demo");
  21. $("<article>").attr("id", "whiteboard").appendTo($("#content")).whiteboard({ucemeeting: meeting});
  22. $("<article>").appendTo($("#content")).sample({ucemeeting: meeting});
  23. meeting.startLoop();
  24. };
  25. }
  26. function onReady() {
  27. var uid = "anonymous_"+ new Date().getTime();
  28. var client = uce.createClient();
  29. var sequence = require('futures').sequence();
  30. sequence.then(createAccount(client, uid));
  31. sequence.then(authUser(client, uid));
  32. sequence.then(startLive(client));
  33. }
  34. })(jQuery);