private void CheckCommands()
 {
     string[] args = Environment.GetCommandLineArgs();
     foreach (string arg in args)
     {
         Debug.Log(arg);
         if (arg == "host")
         {
             Debug.Log("Hosting Server!");
             mm.Host();
         }
     }
 }
Beispiel #2
0
    private IEnumerator HostLobby()
    {
        yield return(new WaitForSeconds(1.5f));

        m_ForgeMultiplayerMenu.Host();
    }
Beispiel #3
0
    IEnumerator LoginUser()
    {
        WWWForm form = new WWWForm();

        form.AddField("name", nameField.text);
        form.AddField("password", passwordField.text);

        UnityWebRequest www = UnityWebRequest.Post($"http://{NetworkConstants.IpAddress}/sqlconnect/login.php", form);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
            InfoText.text = www.error;
        }
        else
        {
            string[] serverData = www.downloadHandler.text.Split('\t');
            if (serverData[0] == "0")
            {
                Debug.Log("User logged in");
                InfoText.text          = "User logged in";
                DBManager.username     = nameField.text;
                DBManager.achievements = new HashSet <string>(serverData[1].Split(',').ToList());
                DBManager.face_recognition_image_location = serverData[2];
                Debug.Log(serverData[3]);
                DBManager.role_id = System.Convert.ToInt32(serverData[3]);
                DBManager.id      = System.Convert.ToInt32(serverData[4]);
                // TODO: microlesson setup
                DBManager.microLesson.LessonName = "virtual_reality";
                //TODO: add presentation_ppt_content to DB
                DBManager.microLesson.presentation_ppt_content = $"http://{NetworkConstants.IpAddress}/presentations/{DBManager.microLesson.LessonName}/"; // C:\MAMP\htdocs\presentations\acauser123\virtual_reality
                Debug.Log(@"C:\MAMP\htdocs\Python\face_recognize_webcam.py" + @" ..\" + DBManager.face_recognition_image_location);
                Debug.Log(DBManager.microLesson.presentation_ppt_content);
                //Without face detection -> GoToVirtualRoom();
                MultiplayerMenu sn = multiPlayerMenu.GetComponent <MultiplayerMenu>();
                if (DBManager.role_id == 1)
                {
                    sn.Host();
                }
                else if (DBManager.role_id == 2)
                {
                    sn.Connect();
                }


                // load ip adress
                form = new WWWForm();
                form.AddField("user_id", DBManager.id);
                www = UnityWebRequest.Post($"http://{NetworkConstants.IpAddress}/sqlconnect/getIpAddress.php", form);
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                    InfoText.text = www.error;
                }
                else
                {
                    Debug.Log("IP address " + www.downloadHandler.text); // TODO: ip address for networking, NetworkConstants.IpAddress is db address
                    //yield return new WaitForSeconds(1);   //Wait
                    //FaceRecognitionManager.Start();
                    GoToVirtualRoom();
                }
            }
            else
            {
                Debug.Log("User logged in failed. Error #" + www.downloadHandler.text);
                InfoText.text = "User logged in failed. Error #" + www.downloadHandler.text;
            }
        }
    }