Logs the current user in one of the server Zones.

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: (1.7.3)


public class LoginRequest : BaseRequest


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.


The following example performs a login in the "SimpleChat" Zone:
 Copy imageCopy
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!");        // Windows Universal
void OnLoginError(BaseEvent evt) {
    Console.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]);                      // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]);     // Windows Universal

Inheritance Hierarchy


See Also