| Package | com.smartfoxserver.v2.requests |
| Class | public class LoginRequest |
| Inheritance | LoginRequest com.smartfoxserver.v2.requests.BaseRequest |
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.
See also
| Method | Defined By | ||
|---|---|---|---|
LoginRequest(userName:String, password:String, zoneName:String, params:ISFSObject = null)
Creates a new LoginRequest instance. | LoginRequest | ||
| 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.
ParametersuserName: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
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);
}