diff --git a/PalaceClient/PalaceClient.js b/PalaceClient/PalaceClient.js index d54e573..6fdf5a3 100644 --- a/PalaceClient/PalaceClient.js +++ b/PalaceClient/PalaceClient.js @@ -199,6 +199,11 @@ function PalaceClient() // extends EventDispatcher return roomList; } + this.getUserList = getUserList; + function getUserList() { + return userList; + } + that.getUserName = function getUserName() { return _userName; }; @@ -650,6 +655,21 @@ function PalaceClient() // extends EventDispatcher var leaveEventHandlers; var requestedRoomId = 0; + this.gotoRoomByUser = gotoRoomByUser; + function gotoRoomByUser(userId) { + userListSize = userList.size(); + + for (var i = 0; i < userListSize; i++) { + var user = userList.getItemAt(i); + if (user instanceof PalaceUser) { + console.log("user.id" + user.id + " userId" + userId + " roomId " + user.roomID); + if (user.id == userId) { + gotoRoom(user.roomID) + } + } + } + } + this.gotoRoom = gotoRoom; function gotoRoom(roomId) { if (!connected || currentRoom.id == roomId) { @@ -1865,6 +1885,9 @@ function PalaceClient() // extends EventDispatcher //trace("User List - got user: " + user.name); userList.addItem(user); } + + var userListEvent = new Event('userList'); + dispatchEvent(userListEvent); // trace("There are " + userList.length + " users in this palace."); } diff --git a/PalaceClient/palace/model/PalaceUser.js b/PalaceClient/palace/model/PalaceUser.js index 0159d37..a9514e4 100644 --- a/PalaceClient/palace/model/PalaceUser.js +++ b/PalaceClient/palace/model/PalaceUser.js @@ -227,8 +227,8 @@ function PalaceUser(palaceClient, propStore) function checkFaceProps()/* :void */ { var showFace/* :Boolean */ = true; - for (var i/* :int */ = 0; i < that.props.length; i++) { - var prop/* :PalaceProp */ = PalaceProp(that.props.getItemAt(i)); + for (var i/* :int */ = 0; i < that.props.size(); i++) { + var prop/* :PalaceProp */ = that.props.getItemAt(i); if (prop.head) { showFace = false; } diff --git a/WebClient/client.css b/WebClient/client.css index 7a6c324..78cff99 100644 --- a/WebClient/client.css +++ b/WebClient/client.css @@ -52,19 +52,22 @@ body { /*margin-right: 3px;*/ } -#room-list-window +#room-list-window, +#user-list-window #log-window { margin: 5px 0 0 5px; border: 1px solid silver; } -#room-list { +#room-list, +#user-list { font-size: 13px; width: 300px; height: 100px; background-color: #eeeeee; overflow: scroll; } + #log { font-size: 13px; width: 300px; diff --git a/WebClient/client.js b/WebClient/client.js index 4c93f8f..964b02b 100644 --- a/WebClient/client.js +++ b/WebClient/client.js @@ -27,6 +27,20 @@ function startSocket() { }); }); + socket.on('userList', function (data) { + var userList = $('#user-list'); + var users = data.data; + + for (var i = 0; i < users.length; i++) { + userList.append('' + '
'); + } + + userList.on('change', function (event) { + var userId = $("#user-list option:selected").val(); + socket.emit('gotoRoomByUser', { 'userId': userId }); + }); + }); + socket.on('chat', function (data) { console.log(data); var logWindow = $('#log'); diff --git a/WebClient/index.html b/WebClient/index.html index 936fac3..70ef8dd 100644 --- a/WebClient/index.html +++ b/WebClient/index.html @@ -36,6 +36,9 @@
Room List
+
User List
+ +
@@ -59,7 +62,6 @@
Log
-
diff --git a/WebClient2/client.css b/WebClient2/client.css index d2a703d..63dfd83 100644 --- a/WebClient2/client.css +++ b/WebClient2/client.css @@ -53,19 +53,22 @@ body { /*margin-right: 3px;*/ } -#room-list-window +#room-list-window, +#user-list-window #log-window { /*margin: 0px;*/ /*border: 1px solid silver;*/ } -#room-list { +#room-list, +#user-list { font-size: 13px; width: 300px; height: 100px; background-color: #eeeeee; overflow: scroll; } + #log { font-size: 13px; width: 300px; diff --git a/WebClient2/client.js b/WebClient2/client.js index 6215dd7..bad5d88 100644 --- a/WebClient2/client.js +++ b/WebClient2/client.js @@ -22,6 +22,16 @@ function startSocket() { w2ui['grid'].add(gridData); }); + socket.on('userList', function (data) { + var users = data.data; +console.log(users); + var gridData = []; + for (var i = 0; i < users.length; i++) { + gridData.push({ recid: users[i].id, userName: users[i].name, roomName: users[i].roomName}); + } + w2ui['userGrid'].add(gridData); + }); + socket.on('chat', function (data) { console.log(data); var logWindow = $('#log'); @@ -160,10 +170,14 @@ function setFace(userId, face, color) { function addProp(userId, userData) { var userDiv = $('#user-' + userId); userDiv.find('.prop').remove(); + var userFace = $('#user-' + userId + ' .face'); + if (userData.showFace) { + userFace.css('visibility', 'visible'); + } else { + userFace.css('visibility', 'hidden'); + } var i; - console.log('propcount: ' + userData.propCount); for (i=0;i
-
+
+
+
+
@@ -53,6 +56,8 @@ $(function () { var roomListWindow = $("#room-list-window"); roomListWindow.dialog({ autoOpen: false, title: "Room List"}); + var userListWindow = $("#user-list-window"); + userListWindow.dialog({ autoOpen: false, title: "User List"}); var logWindow = $("#log"); logWindow.dialog({ autoOpen: true, title: "Log Window"}); @@ -87,6 +92,11 @@ roomListWindow.dialog( "option", "width", 350 ); w2ui['grid'].resize(); } + if (event.target == 'userlist') { + userListWindow.dialog('open'); + userListWindow.dialog( "option", "width", 350 ); + w2ui['userGrid'].resize(); + } if (event.target == 'file' && event.subItem) { if (event.subItem.id == 'login') { $('#login-box').show(500); @@ -109,6 +119,18 @@ socket.emit('gotoRoom', { 'roomName': record.value, 'roomId': record.recid }); } }) + $('#user-list').w2grid({ + name : 'userGrid', + autoLoad: false, + columns : [ + { field: 'userName', caption: 'User', size: '50%' }, + { field: 'roomName', caption: 'Room', size: '50%' } + ], + onClick: function(event) { + var record = (this.get(event.recid)); + socket.emit('gotoRoomByUser', { 'userId': record.recid }); + } + }) }); diff --git a/app.js b/app.js index 154f4be..ac82b74 100644 --- a/app.js +++ b/app.js @@ -96,10 +96,13 @@ appPalace.sockets.on('connection', function (socket) { socket.emit(PalaceEvent.ROOM_CHANGED, palaceClient.currentRoom, palaceClient.get_mediaServer()); }); palaceClient.on('roomList', function (event) { - console.log(palaceClient.getRoomList()); +// console.log(palaceClient.getRoomList()); socket.emit('roomList', palaceClient.getRoomList()); }); - + palaceClient.on('userList', function (event) { +// console.log(palaceClient.getUserList()); + socket.emit('userList', palaceClient.getUserList()); + }); palaceClient.currentRoom.on(PalaceRoomEvent.USER_ENTERED, function (event) { event.user.face = event.user.get_face(); users[event.user.palaceUrl + "/" + event.user.id] = event.user; @@ -160,4 +163,7 @@ appPalace.sockets.on('connection', function (socket) { socket.on("gotoRoom", function (data) { palaceClient.gotoRoom(data.roomId); }); + socket.on("gotoRoomByUser", function (data) { + palaceClient.gotoRoomByUser(data.userId); + }); });