Click or drag to resize

LoginRequest Class

Logs the current user in one of the server Zones.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsLoginRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class LoginRequest : BaseRequest
Constructors
  NameDescription
Public methodLoginRequest(String)
See LoginRequest(string, string, string, ISFSObject) constructor.
Public methodLoginRequest(String, String)
See LoginRequest(string, string, string, ISFSObject) constructor.
Public methodLoginRequest(String, String, String)
See LoginRequest(string, string, string, ISFSObject) constructor.
Public methodLoginRequest(String, String, String, ISFSObject)
Creates a new LoginRequest instance.
Top
Remarks
Each Zone represent an indipendent 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 LOGIN_ERROR event is fired.

Examples
The following example performs a login in the "SimpleChat" Zone:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
    sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);

    // Login
    sfs.Send( new LoginRequest("FozzieTheBear", "", "SimpleChat") );
}

void OnLogin(BaseEvent evt) {
    Console.WriteLine("Login successful!");                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Login successful!");        // UWP
}

void OnLoginError(BaseEvent evt) {
    Console.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]);                      // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]);     // UWP
}
See Also