repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 3fa5f3cb5b4fee1a79d90520b97caa8656ddfbb1:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 3fa5f3cb5b4fee1a79d90520b97caa8656ddfbb1
Author: James Baicoianu 
Date:   Mon Oct 17 02:01:47 2016 -0700

    Send leave_room events when leaving rooms

diff --git a/scripts/external/JanusClientConnection.js b/scripts/external/JanusClientConnection.js
index 26e2c8fc18afe681bea68754b39574f2afae4519..
index ..f0037a46269e2561e49ed9b603b4a4a0d4894b16 100644
--- a/scripts/external/JanusClientConnection.js
+++ b/scripts/external/JanusClientConnection.js
@@ -409,4 +409,12 @@ JanusClientConnection.prototype.enter_room = function(url) {
     }
   });
 };
+JanusClientConnection.prototype.leave_room = function(url) {
+  this.send({
+    'method': 'leave_room',
+    'data': {
+      'roomId': md5(url)
+    }
+  });
+};

diff --git a/scripts/janusweb.js b/scripts/janusweb.js
index 04ce2c227f9f058ccaa0c155e79b7c9816f8e2ad..
index ..573884443971b0f684f29425a27393974186fd9d 100644
--- a/scripts/janusweb.js
+++ b/scripts/janusweb.js
@@ -211,6 +211,7 @@ setTimeout(function() {
         //setTimeout(elation.bind(this.currentroom, this.currentroom.die), 1000);
         //this.currentroom.die();
         this.currentroom.disable();
+        this.leave_room(this.currentroom.url);
         this.currentroom = false;
       }
       this.refresh();
@@ -359,6 +360,11 @@ setTimeout(function() {
         this.network.enter_room(url);
       }
     }
+    this.leave_room = function(url) {
+      if (this.network) {
+        this.network.leave_room(url);
+      }
+    }
     this.onJanusMessage = function(msg) {
       var method = msg.data.method
       if (method == 'user_moved') {
@@ -455,6 +461,7 @@ setTimeout(function() {

       if (remote.room !== room) {
         room.add(remote);
+        remote.room = room;
       }

       if (movedata.dir) {

-----END OF PAGE-----