sfs2x.client.requests
Class LoginRequest

java.lang.Object
  extended by sfs2x.client.requests.BaseRequest
      extended by sfs2x.client.requests.LoginRequest
All Implemented Interfaces:
sfs2x.client.requests.IRequest

public class LoginRequest
extends BaseRequest

Logs the current user in one of the server Zones.

Each Zone represent an independent multiuser application governed by SmartFoxServer. In order to join a Zone, a user name and password are usually required. In order to validate the user credentials, a custom login process should be implemented in the Zone's server-side Extension.

Read the SmartFoxServer 2X documentation about the login process for more informations.

If the login operation is successful, the current user receives a login event; otherwise the loginError event is fired.

Example
The following example performs a login in the "SimpleChat" Zone:

 private void someMethod() {
     sfs.addEventListener(SFSEvent.LOGIN, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("Login successful!");
         }
     });
     sfs.addEventListener(SFSEvent.LOGIN_ERROR, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("Login failure: " + evt.getArguments().get("errorMessage"));
         }
     });
     
     // Login
     sfs.send(new LoginRequest("FozzieTheBear", "", "SimpleChat"));
 }
 

See Also:
SFSEvent.LOGIN, SFSEvent.LOGIN_ERROR

Field Summary
static java.lang.String KEY_ID
          * API internal usage only *
static java.lang.String KEY_PARAMS
          * API internal usage only *
static java.lang.String KEY_PASSWORD
          * API internal usage only *
static java.lang.String KEY_PRIVILEGE_ID
          * API internal usage only *
static java.lang.String KEY_RECONNECTION_SECONDS
          * API internal usage only *
static java.lang.String KEY_ROOMLIST
          * API internal usage only *
static java.lang.String KEY_USER_NAME
          * API internal usage only *
static java.lang.String KEY_ZONE_NAME
          * API internal usage only *
 
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
 
Constructor Summary
LoginRequest(java.lang.String userName)
           
LoginRequest(java.lang.String userName, java.lang.String password)
           
LoginRequest(java.lang.String userName, java.lang.String password, java.lang.String zoneName)
           
LoginRequest(java.lang.String userName, java.lang.String password, java.lang.String zoneName, com.smartfoxserver.v2.entities.data.ISFSObject params)
          Creates a new LoginRequest instance.
 
Method Summary
 void execute(ISmartFox sfs)
          * API internal usage only *
 void validate(ISmartFox sfs)
          * API internal usage only *
 
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_ZONE_NAME

public static final java.lang.String KEY_ZONE_NAME
* API internal usage only *

See Also:
Constant Field Values

KEY_USER_NAME

public static final java.lang.String KEY_USER_NAME
* API internal usage only *

See Also:
Constant Field Values

KEY_PASSWORD

public static final java.lang.String KEY_PASSWORD
* API internal usage only *

See Also:
Constant Field Values

KEY_PARAMS

public static final java.lang.String KEY_PARAMS
* API internal usage only *

See Also:
Constant Field Values

KEY_PRIVILEGE_ID

public static final java.lang.String KEY_PRIVILEGE_ID
* API internal usage only *

See Also:
Constant Field Values

KEY_ID

public static final java.lang.String KEY_ID
* API internal usage only *

See Also:
Constant Field Values

KEY_ROOMLIST

public static final java.lang.String KEY_ROOMLIST
* API internal usage only *

See Also:
Constant Field Values

KEY_RECONNECTION_SECONDS

public static final java.lang.String KEY_RECONNECTION_SECONDS
* API internal usage only *

See Also:
Constant Field Values
Constructor Detail

LoginRequest

public LoginRequest(java.lang.String userName,
                    java.lang.String password,
                    java.lang.String zoneName,
                    com.smartfoxserver.v2.entities.data.ISFSObject params)
Creates a new LoginRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters:
userName - The name to be assigned to the user. If not passed and if the Zone allows guest users, the name is generated automatically by the server.
password - The user password to access the system. SmartFoxServer doesn't offer a default authentication system, so the password must be validated implementing a custom login system in the Zone's server-side Extension.
zoneName - The name (case-sensitive) of the server Zone to login to; if a Zone name is not specified, the client will use the setting loaded via SmartFox.loadConfig() method.
params - An instance of SFSObject containing custom parameters to be passed to the Zone Extension (requires a custom login system to be in place).
See Also:
SmartFox.send(sfs2x.client.requests.IRequest), SmartFox.loadConfig(String, boolean), SFSObject

LoginRequest

public LoginRequest(java.lang.String userName,
                    java.lang.String password,
                    java.lang.String zoneName)
See Also:
LoginRequest(String, String, String, ISFSObject)

LoginRequest

public LoginRequest(java.lang.String userName,
                    java.lang.String password)
See Also:
LoginRequest(String, String, String, ISFSObject)

LoginRequest

public LoginRequest(java.lang.String userName)
See Also:
LoginRequest(String, String, String, ISFSObject)
Method Detail

validate

public void validate(ISmartFox sfs)
              throws sfs2x.client.exceptions.SFSValidationException
* API internal usage only *

Throws:
sfs2x.client.exceptions.SFSValidationException

execute

public void execute(ISmartFox sfs)
* API internal usage only *