getCurrentRoom() null at extension init (sometimes)
getCurrentRoom() null at extension init (sometimes)
After I updated smartfox to last version, i have this error (2-5 times per day at 10,000 room creations):
TypeError: Cannot call method "getId" of null
at this command:
roomId = _server.getCurrentRoom().getId();
This command is on init() function at room's extension.
Rooms are created from users or dynamically from zone extension.
Server is running more than 7 months without this error. It was started yesterday when i updated to 1.6.9.
TypeError: Cannot call method "getId" of null
at this command:
roomId = _server.getCurrentRoom().getId();
This command is on init() function at room's extension.
Rooms are created from users or dynamically from zone extension.
Server is running more than 7 months without this error. It was started yesterday when i updated to 1.6.9.
Also at the same time this warning started: (5-10 times per day...not in same rooms)
INFO | jvm 1 | 2010/09/18 02:32:44 | 02:32:44.035 - [ WARNING ] > Error in extension [ games/framework.as ]: TypeError: Cannot call method "shutdown" of undefined (games/framework.as#1699)
any help? anything i can do? or to think about?
INFO | jvm 1 | 2010/09/18 02:32:44 | 02:32:44.035 - [ WARNING ] > Error in extension [ games/framework.as ]: TypeError: Cannot call method "shutdown" of undefined (games/framework.as#1699)
any help? anything i can do? or to think about?
It does seem odd that you started getting this warning with the latest update. It could be possible that some of your clients are still using the old client API (just a guess) - due to their cache not clearing out yet.
Or perhaps it is an introduced bug in 1.6.9 patch. It does seem odd that _server.getCurrentRoom() would return null for a dynamically added room extension.
If you could provide more detailed information how you dynamically add a new room + extension? Can it be reproducable? Thanks.
Or perhaps it is an introduced bug in 1.6.9 patch. It does seem odd that _server.getCurrentRoom() would return null for a dynamically added room extension.
If you could provide more detailed information how you dynamically add a new room + extension? Can it be reproducable? Thanks.
Smartfox's forum is my daily newspaper.
It is not reproducable. It happens rarely at random times...also for some reason these extensions remain in the memory and catching internal events for all users of the zone (join exit etc.) . My game extension sends one message on userJoin(only on user that joins game) and i see that message every time that i am connecting to the zone default room or other game rooms! (from roomid that was destroyed yesterday) i made handleInternalEvent function to return if currentRoom == null to avoid this!
Client side room creation:
var roomObj=new Object();
roomObj.name=roomName;
roomObj.isGame=true;
roomObj.exitCurrentRoom=false;
roomObj.extension=new Object();
roomObj.extension.name=myParams.eN;
roomObj.extension.script=myParams.eS;
roomObj.maxUsers=maxUsers;
sfs.createRoom(roomObj);
(user is automatically joining)
Server side room creation:
HashMap roomParameters = new HashMap();
roomParameters.put("name", roomname);
roomParameters.put("isGame", "1");
roomParameters.put("maxU", maxPlayers + "");
roomParameters.put("xtName", extensionName);
roomParameters.put("xtClass", extensionScript);
room = helper.createRoom(zone, roomParameters, u, roomVars, null, true, true, true);
helper.joinRoom(_uid, fromRoom, roomid, false, "", false, true);
Moreover, i put UseConcMarkSweepGC option at the same date as smartfox updated i dont know if it is related. Also, i think that this happens if dynamic room is created and user disconnects at the next milliseconds (so room get destroyed immediately but I am not sure). Anything that could help would be my pleasure to listen.
Client side room creation:
var roomObj=new Object();
roomObj.name=roomName;
roomObj.isGame=true;
roomObj.exitCurrentRoom=false;
roomObj.extension=new Object();
roomObj.extension.name=myParams.eN;
roomObj.extension.script=myParams.eS;
roomObj.maxUsers=maxUsers;
sfs.createRoom(roomObj);
(user is automatically joining)
Server side room creation:
HashMap roomParameters = new HashMap();
roomParameters.put("name", roomname);
roomParameters.put("isGame", "1");
roomParameters.put("maxU", maxPlayers + "");
roomParameters.put("xtName", extensionName);
roomParameters.put("xtClass", extensionScript);
room = helper.createRoom(zone, roomParameters, u, roomVars, null, true, true, true);
helper.joinRoom(_uid, fromRoom, roomid, false, "", false, true);
Moreover, i put UseConcMarkSweepGC option at the same date as smartfox updated i dont know if it is related. Also, i think that this happens if dynamic room is created and user disconnects at the next milliseconds (so room get destroyed immediately but I am not sure). Anything that could help would be my pleasure to listen.
it is SFS_PRO_1.6.6 from the 1.6.6 installer, and it was up to dated to the last version. I have solved all issues with if (_server.getCurrentRoom() == null) {return;}
the only remained error that never have seen it before 7 months, with thousands of users every day is that: TypeError: Cannot call method "shutdown" of undefined
(also nothing changed in my extensions)
the only remained error that never have seen it before 7 months, with thousands of users every day is that: TypeError: Cannot call method "shutdown" of undefined
(also nothing changed in my extensions)
function init()
{
try
{
roomId = _server.getCurrentRoom().getId();
}
catch(e)
{
trace("error at as init: " + e)
}
}
function handleInternalEvent(evt)
{
if (_server.getCurrentRoom() == null)
{
trace ("NULLROOM :" + currentRoomId + " quiz")
nullRoom = true;
return;
}
...........code
currentRoomId = evt["room"].getId()
.............code
}
trace:
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: error at as init: TypeError: Cannot call method "getId" of null
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:56 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:57 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:57 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:10:01 | [games/quiz.as]: NULLROOM :undefined quiz
(last lines repeated thousand times for all users that were joining rooms in this zone)
Is there anything i can to to destroy this dynamic room extension that has no room and catch all zone events?
{
try
{
roomId = _server.getCurrentRoom().getId();
}
catch(e)
{
trace("error at as init: " + e)
}
}
function handleInternalEvent(evt)
{
if (_server.getCurrentRoom() == null)
{
trace ("NULLROOM :" + currentRoomId + " quiz")
nullRoom = true;
return;
}
...........code
currentRoomId = evt["room"].getId()
.............code
}
trace:
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: error at as init: TypeError: Cannot call method "getId" of null
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:55 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:56 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:57 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:09:57 | [games/quiz.as]: NULLROOM :undefined quiz
INFO | jvm 1 | 2010/09/24 01:10:01 | [games/quiz.as]: NULLROOM :undefined quiz
(last lines repeated thousand times for all users that were joining rooms in this zone)
Is there anything i can to to destroy this dynamic room extension that has no room and catch all zone events?
it is the same behaviour if i have it in try catch or not.
My extension is at room level this is my problem....the extension is loaded at dynamic rooms...and never get unloaded as the room get destroyed!!!! and the worst is that it acts like a zone level extension after room get destroyed!
it is happening very rarely 1 time after 500-1000 created rooms...it never happened before the update!
My extension is at room level this is my problem....the extension is loaded at dynamic rooms...and never get unloaded as the room get destroyed!!!! and the worst is that it acts like a zone level extension after room get destroyed!
it is happening very rarely 1 time after 500-1000 created rooms...it never happened before the update!
i dont think it is memory leak
i had put a clear extension without code, only getId of currentRoom (at init) and i still getting the error
INFO | jvm 1 | 2010/10/08 08:24:53 | 08:24:53.565 - [ WARNING ] > Could not assign extension [ game ] to Room id= 731
INFO | jvm 1 | 2010/10/08 08:24:53 | [games/gameFramework.as]: error at as init: TypeError: Cannot call method "getId" of null
i had put a clear extension without code, only getId of currentRoom (at init) and i still getting the error
INFO | jvm 1 | 2010/10/08 08:24:53 | 08:24:53.565 - [ WARNING ] > Could not assign extension [ game ] to Room id= 731
INFO | jvm 1 | 2010/10/08 08:24:53 | [games/gameFramework.as]: error at as init: TypeError: Cannot call method "getId" of null