Rhino Usage Warning: Missed Context.javaToJS() conversion

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
MoonChild
Posts: 7
Joined: 04 Dec 2009, 15:06
Location: Netherlands

Rhino Usage Warning: Missed Context.javaToJS() conversion

Post by MoonChild »

I keep getting this warning:
RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object it.gotoandplay.smartfoxserver.data.User@12fb62c of
class it.gotoandplay.smartfoxserver.data.User where it expected String, Number,
Boolean or Scriptable instance. Please check your code for missing Context.java
ToJS() call.
I tried to google for an answer but I haven't found anything that could help me.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Hi,
it looks like you are passing the wrong object in a function call. Probably a User object instead of a userId which is expected as a number.
If you also have the line number of the error please double check your code to make sure you are passing the right arguments.
Lapo
--
gotoAndPlay()
...addicted to flash games
MoonChild
Posts: 7
Joined: 04 Dec 2009, 15:06
Location: Netherlands

Post by MoonChild »

Lapo wrote:Hi,
it looks like you are passing the wrong object in a function call. Probably a User object instead of a userId which is expected as a number.
If you also have the line number of the error please double check your code to make sure you are passing the right arguments.
The warning seems to appear everytime this function gets called

Code: Select all

	//Send Bullet Data
	if (cmd == "send.bulletdata")
	{
		var myZone = _server.getCurrentZone();
		var myRoom = myZone.getRoom(fromRoom);
		var playerID = user.getPlayerIndex();
		var usersInRoom = myRoom.getAllUsers();
		var usersToRespond = new Array();
		
		for (index = 0; index<usersInRoom.length; index++) {
			if (user != usersInRoom[index]) {
				usersToRespond.push( usersInRoom[index] );
			}
		}
		var response = {};
		response._cmd = "receive.bulletdata";
		response.pID = playerID;
		response.pObject = params;
		_server.sendResponse(response, fromRoom, null, myRoom.getAllUsers());
	}
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The for loop that you use to populate the usersToRespond array is not necessary. The Room object exposes a method called getAllUsersButOne().

It works like this:
var usersToRespond = room.getAllUsersButOne(myUser)
It will return an array with all the users in the room except myUser.

Maybe the error is caused in the foor loop. Try removing it and use the above example instead.
Lapo
--
gotoAndPlay()
...addicted to flash games
MoonChild
Posts: 7
Joined: 04 Dec 2009, 15:06
Location: Netherlands

Post by MoonChild »

Lapo wrote:The for loop that you use to populate the usersToRespond array is not necessary. The Room object exposes a method called getAllUsersButOne().

It works like this:
var usersToRespond = room.getAllUsersButOne(myUser)
It will return an array with all the users in the room except myUser.

Maybe the error is caused in the foor loop. Try removing it and use the above example instead.
Well it's replaced and I'm not getting that error anymore. So thanks a lot for your help! :)
Post Reply