Packagecom.smartfoxserver.v2.requests
Classpublic class LoginRequest
InheritanceLoginRequest Inheritance com.smartfoxserver.v2.requests.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.

View the examples

See also

login event
loginError event


Public Methods
 MethodDefined By
  
LoginRequest(userName:String, password:String, zoneName:String, params:ISFSObject = null)
Creates a new LoginRequest instance.
LoginRequest
Constructor Detail
LoginRequest()Constructor
public function LoginRequest(userName:String, password:String, zoneName:String, params:ISFSObject = null)

Creates a new LoginRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters
userName:String — 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:String — 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:String — 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:ISFSObject (default = null) — 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

Examples
The following example performs a login in the "SimpleChat" Zone:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSEvent.LOGIN, onLogin);
         sfs.addEventListener(SFSEvent.LOGIN_ERROR, onLoginError);
         
         // Login
         sfs.send(new LoginRequest("FozzieTheBear", "", "SimpleChat"));
     }
     
     private function onLogin(evt:SFSEvent):void
     {
         trace("Login successful!");
     }
     
     private function onLoginError(evt:SFSEvent):void
     {
         trace("Login failure: " + evt.params.errorMessage);
     }