Packagecom.electrotank.electroserver4.message.request
Classpublic class LoginRequest
InheritanceLoginRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

This class is used to log into the server. By default all that is required here is that you create the request and populate it with a unique user name string. Since login systems can be implemented many different ways depending on the needs of the company or the application being created we have provided a lot of flexibility here. If you want to do anything more than the default login, then you must implement a Login Event Handler on the server. That Login Event Handler can assign you a user name, check your user name and password against a database, or just let you through as-is.


Example
This shows how to log into the server in the most basic way.
    import com.electrotank.electroserver4.ElectroServer;
    import com.electrotank.electroserver4.errors.EsError;
    import com.electrotank.electroserver4.message.MessageType;
    import com.electrotank.electroserver4.message.request.
    import com.electrotank.electroserver4.message.response.
    import com.electrotank.electroserver4.message.event.
    //
    private var es:ElectroServer;//Assume the connection has already been established.
    //Build the request
    var lr:LoginRequest = new LoginRequest();
    lr.setUserName("yoda");
    //Send it
    es.send(lr);
    //Listen for the response
    es.addEventListener(MessageType.LoginResponse, "onLoginResponse", this);
    function onLoginResponse(e:LoginResponse):void {
        if (e.getAccepted()) {
            trace("Logged in!");
        } else if (!e.getAccepted()){
            var err:EsError = e.getEsError();
            trace("Login failed: "+err.getDescription());
        }
    }
     



Public Methods
 MethodDefined by
  
Creates a new instance of the LoginRequest class.
LoginRequest
  
addUserVariable(name:String, value:EsObject):void
Adds a user variable to be set during login.
LoginRequest
  
Gets the optional EsObject.
LoginRequest
  
LoginRequest
  
getPassword():String
Returns the optional password.
LoginRequest
  
getProtocols():Array
LoginRequest
  
getUserName():String
Returns the name to be used during login.
LoginRequest
  
Gets the optional user variables to be set during login.
LoginRequest
  
setEsObject(esObject:EsObject):void
Sets the option EsObjec to be sent to the server.
LoginRequest
  
setIsAutoDiscoverProtocol(isAutoDiscoverProtocol:Boolean):void
LoginRequest
  
setPassword(password:String):void
Sets an optional login password.
LoginRequest
  
setProtocols(protocols:Array):void
LoginRequest
  
setUserName(userName:String):void
The name to be used during login.
LoginRequest
  
setUserVariables(arr:Array):void
Sets a list of user variables to be set during login.
LoginRequest
  
LoginRequest
Constructor detail
LoginRequest()constructor
public function LoginRequest()

Creates a new instance of the LoginRequest class.

Method detail
addUserVariable()method
public function addUserVariable(name:String, value:EsObject):void

Adds a user variable to be set during login.

Parameters
name:String — Variable name.
 
value:EsObject — Variable value.
getEsObject()method 
public function getEsObject():EsObject

Gets the optional EsObject.

Returns
EsObject
getIsAutoDiscoverProtocol()method 
public function getIsAutoDiscoverProtocol():Boolean

Returns
Boolean
getPassword()method 
public function getPassword():String

Returns the optional password.

Returns
String — Returns the optional password.
getProtocols()method 
public function getProtocols():Array

Returns
Array
getUserName()method 
public function getUserName():String

Returns the name to be used during login.

Returns
String
getUserVariables()method 
public function getUserVariables():Array

Gets the optional user variables to be set during login.

Returns
Array — Returns the optional user variables to be set during login.
setEsObject()method 
public function setEsObject(esObject:EsObject):void

Sets the option EsObjec to be sent to the server.

Parameters
esObject:EsObject — The optional EsObjec to be sent to the server.
setIsAutoDiscoverProtocol()method 
public function setIsAutoDiscoverProtocol(isAutoDiscoverProtocol:Boolean):voidParameters
isAutoDiscoverProtocol:Boolean
setPassword()method 
public function setPassword(password:String):void

Sets an optional login password. Passwords are only used by custom-written Login Event Handlers on the server.

Parameters
password:String — Password string.
setProtocols()method 
public function setProtocols(protocols:Array):voidParameters
protocols:Array
setUserName()method 
public function setUserName(userName:String):void

The name to be used during login. This can be null if a Login Event Handler is being used on the server to assign you a user name.

Parameters
userName:String — Name to be used during login.
setUserVariables()method 
public function setUserVariables(arr:Array):void

Sets a list of user variables to be set during login.

Parameters
arr:Array — List of user variables.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse