Issues (27)

app/assets/javascripts/wait.js (4 issues)

1
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2
//
3
// Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
4
//
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU Lesser General Public License as published by the Free Software
7
// Foundation; either version 3.0 of the License, or (at your option) any later
8
// version.
9
//
10
// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
11
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public License along
15
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
16
17
// Handle client request to join when meeting starts.
18
$(document).on("turbolinks:load", function(){
19
  var controller = $("body").data('controller');
20
  var action = $("body").data('action');
21
22
  if(controller == "rooms" && action == "join"){
23
    App.waiting = App.cable.subscriptions.create({
24
      channel: "WaitingChannel",
25
      roomuid: $(".background").attr("room"),
26
      useruid: $(".background").attr("user")
27
    }, {
28
      connected: function() {
29
        console.log("connected");
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
30
      },
31
32
      disconnected: function(data) {
33
        console.log("disconnected");
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
34
        console.log(data);
35
      },
36
37
      rejected: function() {
38
        console.log("rejected");
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
39
      },
40
41
      received: function(data){
42
        console.log(data);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
43
        if(data.action = "started"){
44
          request_to_join_meeting();
45
        }
46
      }
47
    });
48
  }
49
});
50
51
var join_attempts = 0;
52
53
var request_to_join_meeting = function(){
54
  $.ajax({
55
    url: window.location.pathname,
56
    type: 'POST',
57
    data: {
58
      join_name: $(".background").attr("join-name")
59
    },
60
    headers: {
61
      'Content-Type': 'application/x-www-form-urlencoded',
62
      'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
63
    },
64
    success: function(){
65
      // Enqueue another trial just incase they didn't actually join.
66
      if(join_attempts < 4){ setTimeout(request_to_join_meeting, 10000); }
67
      join_attempts++;
68
    }
69
  });
70
}
71