Browse Source

Use room document from Welcome rather than synthesizing a response.

pull/112/head
Lance Cooper 11 years ago committed by Simon Eisenmann
parent
commit
910dd71b81
  1. 3
      doc/CHANNELING-API.txt
  2. 4
      src/app/spreed-webrtc-server/channelling_api_test.go
  3. 2
      static/js/directives/buddylist.js
  4. 4
      static/js/directives/chat.js
  5. 2
      static/js/directives/page.js
  6. 2
      static/js/directives/roombar.js
  7. 2
      static/js/directives/title.js
  8. 3
      static/js/mediastream/api.js
  9. 60
      static/js/services/rooms.js

3
doc/CHANNELING-API.txt

@ -164,7 +164,8 @@ Special purpose documents for channling
Hello document is to be send by the client after connection was established. Hello document is to be send by the client after connection was established.
If an Iid is provided, a Welcome document will be returned if joining the If an Iid is provided, a Welcome document will be returned if joining the
room with the given Id succeeds. Otherwise an Error document with one of the room with the given Id succeeds. Otherwise an Error document with one of the
error codes listed below will be returned. error codes listed below will be returned. Note that any previous room will
have been left regardless of whether the response is successful.
Keys under Hello: Keys under Hello:

4
src/app/spreed-webrtc-server/channelling_api_test.go

@ -189,4 +189,8 @@ func Test_ChannellingAPI_OnIncoming_HelloMessageWithAnIid_RespondsWithAnErrorIfT
if err.Type != "Error" { if err.Type != "Error" {
t.Error("Message did not have the correct type") t.Error("Message did not have the correct type")
} }
if code := "default_room_disabled"; err.Code != code {
t.Errorf("Expected error code to be %v, but was %v", code, err.Code)
}
} }

2
static/js/directives/buddylist.js

@ -45,7 +45,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
updateBuddyListVisibility(); updateBuddyListVisibility();
}); });
$scope.$on("room.joined", function(ev, room) { $scope.$on("room.joined", function(ev) {
inRoom = true; inRoom = true;
updateBuddyListVisibility(); updateBuddyListVisibility();
}); });

4
static/js/directives/chat.js

@ -551,8 +551,8 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
noenable: true, noenable: true,
noactivate: true noactivate: true
}); });
scope.currentRoomName = room.name; scope.currentRoomName = room.Name;
var msg = $("<span>").text(translation._("You are now in room %s ...", room.name)); var msg = $("<span>").text(translation._("You are now in room %s ...", room.Name));
subscope.$broadcast("display", null, $("<i>").append(msg)); subscope.$broadcast("display", null, $("<i>").append(msg));
}); });

2
static/js/directives/page.js

@ -26,7 +26,7 @@ define(['text!partials/page.html', 'text!partials/page/welcome.html'], function(
var link = function($scope, $element, attrs) { var link = function($scope, $element, attrs) {
$scope.randomRoom = rooms.randomRoom; $scope.randomRoom = rooms.randomRoom;
$scope.$on("room.joined", function(event, name) { $scope.$on("room.joined", function(event) {
$scope.page = null; $scope.page = null;
}); });

2
static/js/directives/roombar.js

@ -48,7 +48,7 @@ define(['underscore', 'text!partials/roombar.html'], function(_, template) {
}; };
$scope.$on("room.joined", function(ev, room) { $scope.$on("room.joined", function(ev, room) {
$scope.currentRoomName = $scope.newRoomName = room.name; $scope.currentRoomName = $scope.newRoomName = room.Name;
}); });
$scope.$on("room.left", function(ev) { $scope.$on("room.left", function(ev) {

2
static/js/directives/title.js

@ -31,7 +31,7 @@ define([], function() {
}; };
$scope.$on("room.joined", function(ev, room) { $scope.$on("room.joined", function(ev, room) {
updateTitle(room.name); updateTitle(room.Name);
}); });
$scope.$on("room.left", function(ev) { $scope.$on("room.left", function(ev) {

3
static/js/mediastream/api.js

@ -235,9 +235,10 @@ define(['jquery', 'underscore', 'ua-parser'], function($, _, uaparser) {
var that = this; var that = this;
var onResponse = function(event, type, data) { var onResponse = function(event, type, data) {
console.log("Got response to Hello", data);
if (type === "Welcome") { if (type === "Welcome") {
if (success) { if (success) {
success({name: name}); success(data.Room);
} }
that.e.triggerHandler("received.users", [data.Users]); that.e.triggerHandler("received.users", [data.Users]);
} else { } else {

60
static/js/services/rooms.js

@ -29,6 +29,7 @@ define([
var joinFailed = function(error) { var joinFailed = function(error) {
console.log("error", error, "while joining room"); console.log("error", error, "while joining room");
setCurrentRoom(null);
rooms.randomRoom(); rooms.randomRoom();
}; };
@ -38,7 +39,7 @@ define([
return; return;
} }
if (!connector.connected || requestedRoomName !== currentRoom) { if (!connector.connected || !currentRoom || requestedRoomName !== currentRoom.Name) {
if (requestedRoomName !== "" || globalContext.Cfg.DefaultRoomEnabled) { if (requestedRoomName !== "" || globalContext.Cfg.DefaultRoomEnabled) {
console.log("Joining room", requestedRoomName); console.log("Joining room", requestedRoomName);
requestedRoomName = requestedRoomName ? requestedRoomName : ""; requestedRoomName = requestedRoomName ? requestedRoomName : "";
@ -51,25 +52,20 @@ define([
} }
}; };
// Cache events, to avoid ui flicker during quick room changes.
var nextRoom = null;
var setCurrentRoom = function(room) { var setCurrentRoom = function(room) {
nextRoom = room; if (room === currentRoom) {
return;
$timeout(function() { }
if (nextRoom !== currentRoom) { var priorRoom = currentRoom;
var priorRoom = currentRoom; currentRoom = room;
currentRoom = nextRoom; if (priorRoom) {
if (priorRoom) { console.log("Left room", priorRoom.Name);
console.log("Left room", priorRoom.name); $rootScope.$broadcast("room.left", priorRoom);
$rootScope.$broadcast("room.left", priorRoom); }
} if (currentRoom) {
if (currentRoom) { console.log("Joined room", currentRoom.Name);
console.log("Joined room", currentRoom.name); $rootScope.$broadcast("room.joined", currentRoom);
$rootScope.$broadcast("room.joined", currentRoom); }
}
}
}, 100);
}; };
connector.e.on("close error", function() { connector.e.on("close error", function() {
@ -99,7 +95,7 @@ define([
var rooms = { var rooms = {
inDefaultRoom: function() { inDefaultRoom: function() {
return (currentRoom !== null ? currentRoom.name : requestedRoomName) === ""; return (currentRoom !== null ? currentRoom.Name : requestedRoomName) === "";
}, },
randomRoom: function() { randomRoom: function() {
$http({ $http({
@ -110,17 +106,17 @@ define([
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }
}). }).
success(function(data, status) { success(function(data, status) {
console.info("Retrieved random room data", data); console.info("Retrieved random room data", data);
if (!data.name) { if (!data.name) {
data.name = ""; data.name = "";
} }
$rootScope.$broadcast('room.random', {name: data.name}); $rootScope.$broadcast('room.random', {name: data.name});
}). }).
error(function() { error(function() {
console.error("Failed to retrieve random room data."); console.error("Failed to retrieve random room data.");
$rootScope.$broadcast('room.random', {}); $rootScope.$broadcast('room.random', {});
}); });
}, },
joinByName: function(name, replace) { joinByName: function(name, replace) {
name = $window.encodeURIComponent(name); name = $window.encodeURIComponent(name);
@ -137,7 +133,7 @@ define([
return name; return name;
}, },
link: function(room) { link: function(room) {
var name = room ? room.name : null; var name = room ? room.Name : null;
if (!name) { if (!name) {
name = ""; name = "";
} }

Loading…
Cancel
Save