Page 1 of 1
undefined getChannel
Posted: 17 Jan 2006, 23:32
by rsnail
Any ideas what might cause an undefined getChannel it only happens once every couple users. Shouldn't the getChannel always work if the user is online?
2006/01/17 17:28:35.163 - [ WARNING ] [id: 11] (JavascriptExtension.logASError): Error in extension [ server.as ]: TypeError: Cannot call method "getChannel" of undefined (server.as#401) Line: -514 (MainLib line: 401)
Thanks
rsnail
Posted: 18 Jan 2006, 06:16
by Lapo
Just from the error is not very easy to tell.
The code from the mainlib.as is this:
Code: Select all
else if (userList.length > 0 && response != undefined)
{
var list = new java.util.LinkedList()
for (var i in userList)
{
list.add(userList[i].getChannel())
}
__extension.sendResponse(result, fromRoom, u, list)
}
It basically just loops through the userList array and calls the getChannel() method.
The error could be thrown because some other object was erroneously added to the list or because the User has been disconnected and its not available anymore.
Question: did you by chance add new methods to the array prototype?
Like:
Code: Select all
Array.prototype.myMethod = function()
{
// whatever ...
}
This could be a reason too...
Posted: 18 Jan 2006, 06:20
by Lapo
One more thing. If you want to debug what's going on from inside the mainlib.as you could modify the code starting from line 395 like this:
Code: Select all
else if (userList.length > 0 && response != undefined)
{
var list = new java.util.LinkedList()
for (var i in userList)
{
var u = userList[i]
if (u.getChannel == undefined)
trace("found non-User object at " + i + " type: " + typeof u)
else
list.add(u.getChannel())
}
__extension.sendResponse(result, fromRoom, u, list)
}
Posted: 18 Jan 2006, 15:33
by rsnail
Hello,
Nope, I did not add new methods to the array prototype.
I am using the getUserByChannel() after the loginUser() in an extension, so I can notify the user what their id is, and set a couple user.properties.
Most logins do not show this error, only 1 out of a 100.
I'll add a couple more logging messages to the mainLib.as to track down if it is the same user, or if the user lost connection during login.