I'm having some issues with using the sendPublicMessage method from the client after joining a room from an extension on the server.
SmartfoxServer 1.6.6
config.xml
Code: Select all
...
<DisabledSysEvents>
<event>onJoinRoom</event>
<event>onJoinRoomError</event>
<event>onRoomAdded</event>
<event>onCreateRoomError</event>
</DisabledSysEvents>
<DisabledSysActions>
<action>joinRoom</action>
<action>leaveRoom</action>
<action>createRoom</action>
<action>setUserVariables</action>
</DisabledSysActions>
...
client side
Code: Select all
...
private function onRoomListUpdate(event:SFSEvent):void {
var sendXtObj:Object = new Object();
sendXtObj.u = myVars.getName();
sendXtObj.p = myVars.getPass();
sfs.sendXtMessage("serverRequest", "j", sendXtObj, "json");
}
...
private function sendMsg(event:Event):void {
sfs.sendPublicMessage(msgTextField.text, Global.getLobbyId());
}
...
serverRequest.as
Code: Select all
...
function handleRequest(cmd, params, user, fromRoom, protocol) {
...
var lobbyRoom = zone.getRoomByName("Lobby Room");
var lobbyJoin = _server.joinRoom(user, -1, false, lobbyRoom.getId());
var tradeRoom = zone.getRoomByName("Trade Room");
var tradeJoin = _server.joinRoom(user, lobbyRoom.getId(), false, tradeRoom.getId());
...
zone = _server.getCurrentZone();
var clanRoom = zone.getRoomByName(user.getVariable("clan").getValue());
if (!clanRoom) {
var roomObj = new Object();
roomObj.name = user.getVariable("clan").getValue();
roomObj.isGame = false;
roomObj.maxU = 1000;
var newClanRoom = _server.createRoom(roomObj, user, false, false);
if (newClanRoom != null){
var clanJoin = _server.joinRoom(user, lobbyRoom.getId(), false, newClanRoom.getId());
}
}
Error
Code: Select all
*************************************************************
Warning:
You haven't joined any rooms!
In order to interact with the server you should join at least one room.
Please consult the documentation for more infos.
*************************************************************
Basically, the extension is joining the user in the lobby, but the client doesn't know that. I was almost 100% that the problem was the fact I was disabling the sysEvent onJoinRoom (since it wasn't triggering the joinOK xml), but upon activating it back in, I get the following error on SFS API upon triggering onJoinRoom event:
Code: Select all
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleJoinOk()
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()
which acording to Flash CS4 debugger is in this line on SysHandler.as:
Code: Select all
// Clear the old data, we need to start from a clean list
currRoom.clearUserList()
that I'm guessing its because the currRoom is null (again on SysHandler.as, right above that line)
Code: Select all
var currRoom:Room = sfs.getRoom(roomId)
Problem is, I don't know why