{# Copyright (c) 2014-2016, NVIDIA CORPORATION.  All rights reserved. #}

<!-- Scripts for communicating with the SocketIO server -->
<script type="text/javascript" src="/static/js/socket.io-1.4.5.min.js"></script>
<script>
var socket = io.connect('http://' + document.domain + ':' + location.port + "{{namespace}}");

$(window).bind("beforeunload", function() {
        socket.emit('leave');
        socket.disconnect();
    });

{% if room -%}
    socket.on('connect', function () {
            socket.emit('join', {'room': '{{room}}'});
        });
{% endif -%}


socket.on('reconnect', function () {
    });

socket.on('reconnecting', function () {
    });

socket.on('error', function (error) {
    });

</script>

