Roomlist not sent when using custom login

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
duncanhall
Posts: 29
Joined: 04 May 2008, 14:52
Contact:

Roomlist not sent when using custom login

Post 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?
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post 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;
   }
} 
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post 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
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post by ramindeja »

I guess I had missed that thread. Thanks for resurfacing it though :)
Post Reply