Hi
I'm using latest SFS 1.5.4 version ,AS3 client files and FLEX 2.0
When I call sendModeratorMessage like this
fs.sendModeratorMessage( "reason",
SmartFoxClient.MODMSG_TO_USER,
userToKickId);
On clinet with userId == userToKickId I get
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleModMessage()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::xmlReceived()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleSocketData()
If I call it like this
fs.sendModeratorMessage( "reason",
SmartFoxClient.MODMSG_TO_ZONE);
all users receives the above error.
Problems with sendModeratorMessage
I'm still having that problem - only this time instead in IE debugger - i receive the error inside FLEX(debug mode) here it is, along with some debug info:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleModMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:433]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:84]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::xmlReceived()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:327]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1418]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::handleSocketData()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1401]
this = it.gotoandplay.smartfoxserver.handlers.SysHandler (@33dc311)
handlersTable = Array (@342bb51)
apiKO = Function (@34ea101)
apiOK = Function (@34ea179)
bAdd = Function (@34ea831)
bList = Function (@34ea7e1)
bUpd = Function (@34ea809)
createRmKO = Function (@34ea7b9)
dataObj = Function (@34ea6a1)
dmnMsg = Function (@34ea651)
joinKO = Function (@34ea589)
joinOK = Function (@34ea561)
leaveRoom = Function (@34ea881)
length = 0
logKO = Function (@34ea4c1)
logOK = Function (@34ea0d9)
logout = Function (@34ea4e9)
modMsg = Function (@34ea679)
prvMsg = Function (@34ea629)
pubMsg = Function (@34ea601)
rmList = Function (@34ea511)
rndK = Function (@34ea741)
roomAdd = Function (@34ea6f1)
roomB = Function (@34ea859)
roomDel = Function (@34ea719)
roundTripRes = Function (@34ea769)
rVarsUpdate = Function (@34ea6c9)
swSpec = Function (@34ea8a9)
uCount = Function (@34ea539)
uER = Function (@34ea5b1)
userGone = Function (@34ea5d9)
uVarsUpdate = Function (@34ea791)
sfs = it.gotoandplay.smartfoxserver.SmartFoxClient (@3383f61)
activeRoomId = 28 [0x1c]
amIModerator = false
buddyList = Array (@36a24f1)
length = 0
buddyVars = Array (@36a27c1)
length = 0
changingRoom = false
debug = false
httpPort = 0
isConnected = true
myUserId = 3
myUserName = "vas11"
playerId = 0
rawProtocolSeparator = "%"
o = XML
<msg t="sys">
<body action="modMsg" r="0">
<user id="1"/>
<txt>
<![CDATA[some reason]]>
</txt>
</body>
</msg>
roomId = 0
userId = 1
message = "some reason"
sender = null
params = null
evt = null
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleModMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:433]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:84]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::xmlReceived()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:327]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1418]
at it.gotoandplay.smartfoxserver::SmartFoxClient/it.gotoandplay.smartfoxserver:SmartFoxClient::handleSocketData()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1401]
this = it.gotoandplay.smartfoxserver.handlers.SysHandler (@33dc311)
handlersTable = Array (@342bb51)
apiKO = Function (@34ea101)
apiOK = Function (@34ea179)
bAdd = Function (@34ea831)
bList = Function (@34ea7e1)
bUpd = Function (@34ea809)
createRmKO = Function (@34ea7b9)
dataObj = Function (@34ea6a1)
dmnMsg = Function (@34ea651)
joinKO = Function (@34ea589)
joinOK = Function (@34ea561)
leaveRoom = Function (@34ea881)
length = 0
logKO = Function (@34ea4c1)
logOK = Function (@34ea0d9)
logout = Function (@34ea4e9)
modMsg = Function (@34ea679)
prvMsg = Function (@34ea629)
pubMsg = Function (@34ea601)
rmList = Function (@34ea511)
rndK = Function (@34ea741)
roomAdd = Function (@34ea6f1)
roomB = Function (@34ea859)
roomDel = Function (@34ea719)
roundTripRes = Function (@34ea769)
rVarsUpdate = Function (@34ea6c9)
swSpec = Function (@34ea8a9)
uCount = Function (@34ea539)
uER = Function (@34ea5b1)
userGone = Function (@34ea5d9)
uVarsUpdate = Function (@34ea791)
sfs = it.gotoandplay.smartfoxserver.SmartFoxClient (@3383f61)
activeRoomId = 28 [0x1c]
amIModerator = false
buddyList = Array (@36a24f1)
length = 0
buddyVars = Array (@36a27c1)
length = 0
changingRoom = false
debug = false
httpPort = 0
isConnected = true
myUserId = 3
myUserName = "vas11"
playerId = 0
rawProtocolSeparator = "%"
o = XML
<msg t="sys">
<body action="modMsg" r="0">
<user id="1"/>
<txt>
<![CDATA[some reason]]>
</txt>
</body>
</msg>
roomId = 0
userId = 1
message = "some reason"
sender = null
params = null
evt = null
Just an idea there write that the userId is 0. Are you sure that the room where the moderator(the user that sends the message) is is with Id ==0? Please check with activeRoomId(it's important to check it with this).
And are you sure the sender have moderator privileges - please check with amIModerator(i suppose the error is not here but just in case).
And also is there any error(or warning) message on server side?
And are you sure the sender have moderator privileges - please check with amIModerator(i suppose the error is not here but just in case).
And also is there any error(or warning) message on server side?
[Sending]: <msg t='sys'><body action='modMsg' r='28'><txt t='u' id='6'><![CDATA[some reson]]></txt></body></msg>
[ RECEIVED ]: <msg t='sys'><body action='modMsg' r='0'><user id='10' /><txt><![CDATA[some reason]]></txt></body></msg>, (len: 104)
Both users are in Lobby room. If r in xml message is roomId - I have no idea why when moderator is sending message roomId is 28 , but when user receive the message roomId is 0
<Zone name="myZone" roomListVars="true" uCountUpdate="true" buddyList="20" maxUsers="100" customLogin="false">
<Rooms>
<Room name="Lobby" maxUsers="1000" isPrivate="false" isTemp="false" autoJoin="false" uCountUpdate="true" />
</Rooms>
<Moderators status="on">
<Mod name="mod1" pwd="" />
</Moderators>
<Extensions>
<extension name="myExtention" className="myExtention" type="java" />
</Extensions>
</Zone>
[ RECEIVED ]: <msg t='sys'><body action='modMsg' r='0'><user id='10' /><txt><![CDATA[some reason]]></txt></body></msg>, (len: 104)
Both users are in Lobby room. If r in xml message is roomId - I have no idea why when moderator is sending message roomId is 28 , but when user receive the message roomId is 0
<Zone name="myZone" roomListVars="true" uCountUpdate="true" buddyList="20" maxUsers="100" customLogin="false">
<Rooms>
<Room name="Lobby" maxUsers="1000" isPrivate="false" isTemp="false" autoJoin="false" uCountUpdate="true" />
</Rooms>
<Moderators status="on">
<Mod name="mod1" pwd="" />
</Moderators>
<Extensions>
<extension name="myExtention" className="myExtention" type="java" />
</Extensions>
</Zone>
Yep it's looks like as I said the problem is that the roomId is 0.
I've tried it with 1.5.4 with AS 2 API and I have the same problem. On the moderator side the roomId from where the modMessage is send is correct but the other users(and the moderator since I've tried it with MODMSG_TO_ROOM) receive the message with roomId == 0.
It's looks like the problem is on the server side.
I haven't tried with 1.5.5 since I haven't install it yet.
I've tried it with 1.5.4 with AS 2 API and I have the same problem. On the moderator side the roomId from where the modMessage is send is correct but the other users(and the moderator since I've tried it with MODMSG_TO_ROOM) receive the message with roomId == 0.
It's looks like the problem is on the server side.
I haven't tried with 1.5.5 since I haven't install it yet.
Hmm...
Now it's more interesting... I installed the 1.5.5 pro and get this
I use AS2 API because I have application written in AS2 that used mod messages and I'm too lazy to create test for flex
. But I suppose that doesn't change much.
On the client side when a moderator message is received the onModeratorMessage is fired - with two arguments - the message and the user that sends the message. Actually the second argument it's not documented in the docs. It gets the user from the room with id equal to that received - in our case 0. And since there is no room with that id it tries to access the property of null object reference. And since Flash 8 is not so "sensitive" to such kind of errors I even haven't notice that there is a problem - I use only the first argument of the onModeratorMessage and since the Flash 8 doesn't display an error I haven't notice that there is a problem
.
So I suppose that AS3 API use similar code as AS2 API and the wrong room id number causes this problem.
Of course everything I say is based on my own knowledge about how SFS client side API works. May be the things are different I don't know - I just share my opinion.
Now it's more interesting... I installed the 1.5.5 pro and get this
Code: Select all
[Sending]: <msg t='sys'><body action='modMsg' r='1'><txt t='r' id='1'><![CDATA[qwerty]]></txt></body></msg>
[Received]: <msg t="sys"><body action="modMsg" r="0"><user id="2" /><txt>qwerty</txt></body></msg>
On the client side when a moderator message is received the onModeratorMessage is fired - with two arguments - the message and the user that sends the message. Actually the second argument it's not documented in the docs. It gets the user from the room with id equal to that received - in our case 0. And since there is no room with that id it tries to access the property of null object reference. And since Flash 8 is not so "sensitive" to such kind of errors I even haven't notice that there is a problem - I use only the first argument of the onModeratorMessage and since the Flash 8 doesn't display an error I haven't notice that there is a problem
So I suppose that AS3 API use similar code as AS2 API and the wrong room id number causes this problem.
Of course everything I say is based on my own knowledge about how SFS client side API works. May be the things are different I don't know - I just share my opinion.