getRoomList damage User Object!
getRoomList damage User Object!
Hi! I have problem!
For example:
1. Visit site http://www.redhill.pl/simpleChat.html
2. Login in chat (ex. person1)
3.Again visit http://www.redhill.pl/simpleChat.html
4. Login in chat (ex. person2)
And now:
1. Click 'send var' button from person2
2. Go to chat window from person1
Person1 have a information who update variables:
"Update from: person2"
and it's OK! But:
1. Click 'getRoomList' button in chat window from person1 (execute .getRoomList() action)
2. Go to chat window from person2 and once again click 'send var' button
3. Go to chat window from person1
Person1 have a information:
"Update from: undefined" ! ! !
Afert .getRoomList() in .onUserVariablesUpdate(userObj:User) userObj is undefined!
Why???
My SmartFox sever version is 1.5.1 BASIC
For example:
1. Visit site http://www.redhill.pl/simpleChat.html
2. Login in chat (ex. person1)
3.Again visit http://www.redhill.pl/simpleChat.html
4. Login in chat (ex. person2)
And now:
1. Click 'send var' button from person2
2. Go to chat window from person1
Person1 have a information who update variables:
"Update from: person2"
and it's OK! But:
1. Click 'getRoomList' button in chat window from person1 (execute .getRoomList() action)
2. Go to chat window from person2 and once again click 'send var' button
3. Go to chat window from person1
Person1 have a information:
"Update from: undefined" ! ! !
Afert .getRoomList() in .onUserVariablesUpdate(userObj:User) userObj is undefined!
Why???
My SmartFox sever version is 1.5.1 BASIC
Hmm...
Could you give the onRoomListUpdate code. When you call getRoomList() and the SFS on the client side receive the room list it fires the onRoomListUpdate event. Actually may be there is the code that join the user to the room and may be that what cause the problem.
And one question why you need getRoomList() ?
Could you give the onRoomListUpdate code. When you call getRoomList() and the SFS on the client side receive the room list it fires the onRoomListUpdate event. Actually may be there is the code that join the user to the room and may be that what cause the problem.
And one question why you need getRoomList() ?
I need getRoomList() because in my other project attributes in zone "uCountUpdate" is false to save bandwidth and I need getRoomList() for refresh users in rooms.
I think that maybe only my project this not work, but as you can see here too not work.
http://www.redhill.pl/simpleChat.html <- this is for example only.
I think that maybe only my project this not work, but as you can see here too not work.
http://www.redhill.pl/simpleChat.html <- this is for example only.
There is one more issue - after getRoomList() try to type a message - you'll see "undefined" instead of your name.
Could you give the onRoomListUpdate code. I'm almost sure that there is the problem.
Could you give the onRoomListUpdate code. I'm almost sure that there is the problem.
Last edited by patso on 18 Jun 2007, 13:02, edited 1 time in total.
Code is a very simple, because I wanted only show, that always after .getRoomList() my user object and his properties/method are damaged (undefined).
Events onUserVariablesUpdate(userObj:User) or onObjectReceived(obj:Object, sender:User) -> parameters userObj and sender always after call .getRoomList are undefined, but before .getRoomList all it's OK!
Code:
Events onUserVariablesUpdate(userObj:User) or onObjectReceived(obj:Object, sender:User) -> parameters userObj and sender always after call .getRoomList are undefined, but before .getRoomList all it's OK!
Code:
Code: Select all
smartfox.onRoomListUpdate = function(roomList:Object) {
chat_txt.text += newline+"Room list update...";
}
Hi again! 
I wrote complete new example for .getRoomList():
1. Visit http://www.redhill.pl/info.html (connect and login is automatical)
2. And now click green button 'get room information' (execute action .getRoom).
3. In the textarea we have a new information:
"Name room is: The Hall
User in room: Junior"
That's OK! But if you click blue button 'getRoomList()' (execute action .getRoomList()) and once again click green button for information who is in a room we have a new information only with name this room. After .getRoomList() user list is lost!! Why?
Code it's here:
room.getUserList() returns a list of user objects, but after .getRoomList() returns nothing!
I wrote complete new example for .getRoomList():
1. Visit http://www.redhill.pl/info.html (connect and login is automatical)
2. And now click green button 'get room information' (execute action .getRoom).
3. In the textarea we have a new information:
"Name room is: The Hall
User in room: Junior"
That's OK! But if you click blue button 'getRoomList()' (execute action .getRoomList()) and once again click green button for information who is in a room we have a new information only with name this room. After .getRoomList() user list is lost!! Why?
Code it's here:
Code: Select all
import it.gotoandplay.smartfoxserver.*;
var smartfox:SmartFoxClient = new SmartFoxClient();
var inRoom:Boolean = false;
smartfox.onConnection = function(success) {
if (success) {
out_txt.text = "Connected..."+newline;
smartfox.login("simpleChat", "Junior");
} else {
out_txt.text = "Not Connected...";
}
};
smartfox.onLogin = function(resObj:Object) {
if (resObj.success) {
out_txt.text += "Login as: "+resObj.name+newline;
} else {
out_txt.text += "Login failed: "+resObj.error;
}
};
smartfox.onRoomListUpdate = function(lista:Object) {
if (!inRoom) {
out_txt.text += "Room list is downloaded..."+newline;
smartfox.autoJoin();
inRoom=true;
} else {
out_txt.text += "Room list is downloaded..."+newline;
}
};
smartfox.onJoinRoom = function(room:Room) {
out_txt.text += "Enter in: "+room.getName()+newline;
};
System.security.loadPolicyFile("xmlsocket://85.214.87.139:4994");
smartfox.connect("85.214.87.139", 4994);
getRoomList_btn.onRelease = function() {
smartfox.getRoomList();
};
getInfo_btn.onRelease = function() {
var room:Room = smartfox.getRoom(13);
out_txt.text += "Name room is: "+room.getName()+newline;
var list:Object = room.getUserList();
for (var r in list) {
out_txt.text += "User in room: "+list[r].getName()+newline;
}
};
stop();
The problem is in this how SFS populates the room list. When you request the room list - you get exactly this - the room list, you don't receive info about the users that are in the rooms(except user and spectators count).
When you join to a room then you receive the user list - the list with the user and their variables.
How this process look like of the client side AS API point of view. sfs keeps a array with the rooms. When you invoke a getRoomList() the sfs client requests the room list from the server and recreate the room array. This means that all info that SFS previously know about this rooms is lost (including the room list).
One solution is to join to the room again - this way the server will send the user list of that room again. The problem is that SFS will not allow you to join in room if you are already in it. This means that you must leave the room and join it again. And since the only way to leave a room is to join another room you can create a room in which you users joins and then join again in the previous room. But as you see this is very dumb solution.
Solution number two is to use server side extension to update the user count(or to enable the user count in the sfs config file).
When you join to a room then you receive the user list - the list with the user and their variables.
How this process look like of the client side AS API point of view. sfs keeps a array with the rooms. When you invoke a getRoomList() the sfs client requests the room list from the server and recreate the room array. This means that all info that SFS previously know about this rooms is lost (including the room list).
One solution is to join to the room again - this way the server will send the user list of that room again. The problem is that SFS will not allow you to join in room if you are already in it. This means that you must leave the room and join it again. And since the only way to leave a room is to join another room you can create a room in which you users joins and then join again in the previous room. But as you see this is very dumb solution.
Solution number two is to use server side extension to update the user count(or to enable the user count in the sfs config file).
You are welcome (btw cool avatar).redhill wrote:Ok, thanks for all answers, patso.
I must find new solution...
One other solution to modify the client side AS API and make it not to delete the previous data - insted of this merge it with already known one. This one I recommend only if know very well how SFS works.redhill wrote: EDIT:
UNFORTUNATELY is one solution -> uCountUpdate=true, so solution number two.
I do not use server side extension, because SFS PRO is too expensive for me
Actually the turning uCountUpdate to true is not so bad. It depends how often you request the room list but this way you may create more traffic than turning uCountUpdate to true
Maybe that good idea, but I don't know how works SmartFoxpatso wrote:One other solution to modify the client side AS API and make it not to delete the previous data - insted of this merge it with already known one. This one I recommend only if know very well how SFS works.
In this moment it remains only turn on in uCountUpdate or buy SFS PRO or learn structure AS API...hehe.
Ok, topic is closed -> thanks for ideas, patso!
The BEST multiuser server:
1. SmartFoxServer ! ! !
2. Cubeia Firebase
3. ElectroServer
1. SmartFoxServer ! ! !
2. Cubeia Firebase
3. ElectroServer