PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 3    $(document).ready(onReady);
 4
 5    function createAccount(client, uid) {
 6        return function(next) {
 7            client.user.register(uid, "none", "", {}, function(err, result) {
 8                next();
 9            });
10        };
11    }
12
13    function authUser(client, uid) {
14        return function(next) {
15            client.auth(uid, "", function(err, result) {
16                client.attachPresence(result);
17                next();
18            });
19        };
20    }
21
22    function startLive(client) {
23        return function() {
24            var meeting = client.meeting("demo");
25            $("<article>").attr("id", "whiteboard").appendTo($("#content")).whiteboard({ucemeeting: meeting});
26            $("<article>").appendTo($("#content")).sample({ucemeeting: meeting});
27            meeting.startLoop();
28        };
29    }
30
31    function onReady() {
32        var uid = "anonymous_"+ new Date().getTime();
33        var client = uce.createClient();
34        var sequence = require('futures').sequence();
35        sequence.then(createAccount(client, uid));
36        sequence.then(authUser(client, uid));
37        sequence.then(startLive(client));
38    }
39
40})(jQuery);