Exemplo n.º 1
0
 public static void Disconnect()
 {
     LWLogin.Logout();
     NetworkManager.singleton.StopClient();
     NetworkManager.singleton.StopServer();
     LWInterface.NewNotification("Disconnected.", LWInterface.Notification.LWNotificationType.Message);
 }
Exemplo n.º 2
0
        public static IEnumerator Login()
        {
            if (Credentials.user_email != "" && Credentials.user_password != "")
            {
                LWInterface.NewNotification("Attempting to log in..", LWInterface.Notification.LWNotificationType.Message);
                WWWForm requestForm = new WWWForm();
                requestForm.AddField("email", Credentials.user_email);
                requestForm.AddField("password", Credentials.user_password);
                WWW request = new WWW(Domain, requestForm);

                yield return(request);

                string requestText = request.text;

                if (requestText != "NLI")
                {
                    string[] creds;
                    char     delim = '&';
                    creds = requestText.Split(delim);

                    Credentials.SetUser(creds[0], creds[1]);
                    isLoggedIn = true;

                    if (LoginMode == LWLoginMode.automatic_connection)
                    {
                        LWInterface.NewNotification(Credentials.user_name + " logged in. Connecting...", LWInterface.Notification.LWNotificationType.Success);
                        LWNetwork.Client.InitializeClient();
                    }
                    else
                    {
                        LWInterface.NewNotification(Credentials.user_name + " logged in.", LWInterface.Notification.LWNotificationType.Success);
                    }
                    //Automatically connect after logging in if configured to do so
                }
                else
                {
                    LWInterface.NewNotification("Incorrect login.", LWInterface.Notification.LWNotificationType.Error);
                    //Do something else if the login is invalid
                }
                //If the page does not return "NLI", the login is valid
                //Otherwise, the incorrect credentials were provided

                Credentials.ClearLogin();
                //Clear the user's login credentials, regardless of their validity
            }
            else
            {
                Debug.LogError("Login credentials not set, use LWLogin.Credentials.SetLogin()");
            }
        }
Exemplo n.º 3
0
            public static void InitializeServer()
            {
                if (NetworkMode == LWNetworkModes.dev_server)
                {
                    NetworkManager.singleton.networkPort = 7778;
                    NetworkManager.singleton.StartServer();
                    LWInterface.NewNotification("Dev server ready", LWInterface.Notification.LWNotificationType.Success);
                }
                else if (NetworkMode == LWNetworkModes.rel_server)
                {
                    NetworkManager.singleton.networkPort = 7777;
                    NetworkManager.singleton.StartServer();
                    LWInterface.NewNotification("Rel server ready", LWInterface.Notification.LWNotificationType.Success);
                }
                else
                {
                    Debug.LogError("Not in any server mode, adjust LWNetwork.NetworkMode");
                }

                //Start server on 7778 if using development server
                //Start server on 7777 if using release server
                //Otherwise, log an error for no server mode
            }
Exemplo n.º 4
0
 void OnClientConnect()
 {
     LWInterface.NewNotification("Connected!", Notification.LWNotificationType.Success);
 }