Big problem, little time!!!!!!! [URGENT]

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Big problem, little time!!!!!!! [URGENT]

Post by Flappi282 »

Hello yet again everyone!
With one day until my game is releasing, I have found a major bug
All of the game (apart from login and connection) is based server side, including the item parsing, room joining etc...

The problem is that the player cannot join a room they just came from. The console outputs the user is already in this room. But on the server side, it is running a _server.joinRoom.

The problem is that the leaveRoom parameter is set to true.

To fix this, I tried to add _server.leaveRoom(user, fromRoom);

This, however, made absolutely no difference


Heres the code for the joinRoom event

Code: Select all

	} else if (cmd == "j") {
		var rID = params[0];
		if (Number(rID) == -1) {
			rID = chooseStartRoom();
		}
		var roomObj = _zone.getRoom(Number(rID));
		if (roomObj != null) {
			_server.leaveRoom(user,fromRoom);
			
			if (_server.joinRoom(user, fromRoom, true, Number(rID), null, null, false)) {
				user.properties.put("x",330);
				user.properties.put("y",300);
				var res = [];
				res[0] = "j";
				res[1] = roomObj.getId();
				res[2] = roomObj.getName();
				var userList = roomObj.getAllUsers();
				res.push("0|ZobbieBot|1|0|0|0|0|0|0|1|330|300");
				for (var i in userList) {
					if (userList[i].properties.get("hidden") != false && userList[i].properties.get("id") != user.properties.get("id")) {
						res.push(userList[i].properties.get("id") + "|" + userList[i].getName() + "|" + userList[i].properties.get("colour") + "|" + userList[i].properties.get("head") + "|" + userList[i].properties.get("face") + "|" + userList[i].properties.get("neck") + "|" + userList[i].properties.get("body") + "|" + userList[i].properties.get("hands") + "|" + userList[i].properties.get("feet") + "|" + userList[i].properties.get("rank") + "|" + userList[i].properties.get("x") + "|" + userList[i].properties.get("y"));
					}
				}
				_server.sendResponse(res,-1,null,[user],"str");
				var userStr = user.properties.get("id") + "|" + user.getName() + "|" + user.properties.get("colour") + "|" + user.properties.get("head") + "|" + user.properties.get("face") + "|" + user.properties.get("neck") + "|" + user.properties.get("body") + "|" + user.properties.get("hands") + "|" + user.properties.get("feet") + "|" + user.properties.get("rank") + "|" + user.properties.get("x") + "|" + user.properties.get("y");
				_server.sendResponse(["ap", userStr],-1,null,userList,"str");
			} else {
				_server.sendResponse(["j", "0", "10"],-1,null,[user],"str");
			}
		} else {
			_server.sendResponse(["j", "0", "3"],-1,null,[user],"str");
		}
	}
If you look at the code, the leaveRoom event is being fired, and so is the userExit internal event, but the user doesn't leave the room.


In case they are needed, here are the errors that are represented by numbers

Error 3: System error, room not found
Error 10: Room Full, try again later

And the error that is returned is code 10, but the debug is that the user is already in the room.

Why isn't the leaveRoom function working?
--
Flappi282
trueicecold
Posts: 84
Joined: 11 Oct 2009, 11:46
Contact:

Post by trueicecold »

Are you logging in with the foceLogin parameter set to true? it might be a matter of ghosts users, and logging in again with forceLogin will disconnect the old user.
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Post by Flappi282 »

trueicecold wrote:Are you logging in with the foceLogin parameter set to true? it might be a matter of ghosts users, and logging in again with forceLogin will disconnect the old user.
Nope, since I this happens the first time I login. I can join the room (Town) successfully the first time, but when I join the shop, and try to leave, it tells me I'm already in the room, which I'm not
--
Flappi282
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Post by Flappi282 »

Hmm, it seems if I broadcast the event to the clients, the player would leave the room. But for some reason, if I disable broadcast, it doesnt leave the original room.

But I need to disable broadcast, otherwise more bandwidth is used, which I don't want
--
Flappi282
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

In the joinRoom method, you specified 'true' to 'leave current room' (3rd param) - so that's why leaveRoom doesn't really do anything.

It looks like your client was trying to join a room that s/he was already in. Have you performed a check on client side to determine whether or not that user is already in that room prior to joining it?

Also, you mentioned that you prevented broadcasting of an event. Which one?
Smartfox's forum is my daily newspaper.
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Post by Flappi282 »

The problem is, I think this might be a bug, is that if the Join Room event is broadcasted, the user leaves the room. But when the join room event isn't broadcasted, regardless that the leaveRoom flag is set to true, the user doesn't leave the room.

The client side doesn't use the SFS api, it only uses extensions.

On the server side, after the room was being joined, I traced the rooms the user was in. It traced all the rooms the user had joined.

So basically, if the event isn't broadcasted, the user won't leave the room.
--
Flappi282
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The broadcast updates the client, not the server.
It's not clear where do you see the user not leaving the Room. If it's the client then of course you already have the answer.
But I need to disable broadcast, otherwise more bandwidth is used, which I don't want
Ok... it's good to check bandwidth usage, but stopping necessary system updates will break the API. Please allow the update to be sent.
Lapo
--
gotoAndPlay()
...addicted to flash games
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Post by Flappi282 »

I see what you mean. But I also see that Club Penguin got it working. That the user doesn't leave the room when I ran the function is either a bug or just a mistake I made, I don't understand how they do it just fine.
--
Flappi282
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

can you provide an example about it? What does club penguin do?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Flappi282
Posts: 158
Joined: 20 May 2009, 17:51
Contact:

Post by Flappi282 »

As I have found, Club Penguin uses a _server.joinRoom from the server side, but has broadcastEvent turned off, which I cannot do without causing the player to get stuck in that room.

The solution was to turn on broadcastEvent, but this sent a <msg t="sys"> packet to my game, which does nothing but waste bandwidth, since my game is server sided
--
Flappi282
Rutter
Posts: 99
Joined: 12 Dec 2007, 16:21
Location: Canada
Contact:

Post by Rutter »

Don't compare yourself to CP yet. If you get to the concurrent volume they have then you can worry about bandwidth, for now just let the server broadcast the event.
Post Reply