Page 1 of 1
Roomlist not sent when using custom login
Posted: 22 May 2008, 11:27
by duncanhall
As per the smartfox docs/examples, my app is set up to listen for an onRoomListUpdate event, when logging in, meaning I have a reference to the current roomList when entering the lobby.
However, after implementing the 'Secure Login Example' in the docs, the onRoomListUpdate is never triggered.
When using a custom login handler, do I have to manually request the roomList from the client after logging in?
Posted: 22 May 2008, 19:16
by ramindeja
Do a search and you see that there are a few threads regarding this problem.
When you create a custom login, SmartFox default login mechanism is deactivated and you have do a couple of things yourself, nothing major:
Server-Side:
Code: Select all
function handleInternalEvent(pEvent)
{
var response = {};
response.status = false;
if (pEvent.name == "loginRequest") {
// do your own validations here
// if OK, do the REAL LOGIN
var obj = _server.loginUser(pEvent.nick, pEvent.pass, pEvent.chan);
if (obj.success == true) {
// make sure you return the userId and userName back to client
var user = _server.getUserByChannel(pEvent.chan);
var userId = user.getUserId();
var userName = user.getName();
// setup the response props
response.status = true;
response.cmd = "login";
response.myUserId = userId;
response.myUserName = userName;
}
}
_server.sendResponse(response, -1, null, pEvent.chan);
}
Client-Side:
Code: Select all
// listen to this event
smartfox.addEventListener(SFSEvent.onExtensionResponse, extensionResponseHandler);
private function extensionResponseHandler(pEvent:SFSEvent):void
{
var response:Object = pEvent.params.dataObj;
switch (response.cmd) {
case "login":
// if you don't set this,
// other APIs and events won't function properly
smartfox.myUserId = response.myUserId;
smartfox.myUserName = response.myUserName;
// have to do this manually to get the RoomListupdate event
smartfox.getRoomList();
break;
}
}
Posted: 22 May 2008, 21:03
by BigFIsh
When you create a custom login, SmartFox default login mechanism is deactivated and you have do a couple of things yourself, nothing major:
I thought so too, but Lapo said we can call the default login from our custom login
http://forums.smartfoxserver.com/viewtopic.php?t=3021
Posted: 22 May 2008, 21:06
by ramindeja
I guess I had missed that thread. Thanks for resurfacing it though
