예제 #1
0
    void Start()
    {
        xayaClient              = GetComponent <XAYAClient>();
        shipsdClient            = GetComponent <ShipSDClient>();
        GlobalData.gErrorBox    = errorPopup;
        GlobalData.gErrorText   = errorText;
        GlobalData.gSettingInfo = SettingInfo.getSettingFromJson();
        //============ get user info from cookie ========================//
        Debug.Log(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData));
        if (File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\xaya\\.cookie"))
        {
            string   cookieStr = File.ReadAllText(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\xaya\\.cookie");
            string[] userInfo  = cookieStr.Split(':');
            if (userInfo != null && userInfo.Length > 1)
            {
                GlobalData.gSettingInfo.rpcUserName     = userInfo[0];
                GlobalData.gSettingInfo.rpcUserPassword = userInfo[1];
            }
        }
        //===============================================================//

        inputXayaURL.text         = GlobalData.gSettingInfo.xayaURL;
        inputRpcUserName.text     = GlobalData.gSettingInfo.rpcUserName;
        inputRpcUserPassword.text = GlobalData.gSettingInfo.rpcUserPassword;
        inputGSPIP.text           = GlobalData.gSettingInfo.GSPIP;

        //---------------------------------------------//
        if (shipsdClient.IsRunningGSPServer())
        {
            checkLocalGSP.isOn = true;
            checkLocalGSP.transform.GetChild(0).GetChild(0).gameObject.SetActive(true);
        }

        //------------- check running xayad-------------------------//

/*
 *      bool running = false;
 *
 *          try
 *          {
 *          foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName("xayad"))
 *          {
 *              running = true;
 *          }
 #if UNITY_STANDALONE_LINUX
 *          foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName("xaya-qt"))
 *          {
 *              running = true;
 *          }
 *          foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName("./xaya-qt"))
 *          {
 *              running = true;
 *          }
 #endif
 *      }
 *      catch
 *      {
 *
 *
 *      }
 *
 *      if (!running)
 *      {
 *          GlobalData.ErrorPopup("Xaya Service is not running.\nYou must run xaya and restart application.");
 *          errorCloseBtn.GetComponent<Button>().onClick.AddListener(delegate {
 *              UnityEngine.SceneManagement.SceneManager.UnloadScene(0);
 *              Application.Quit();
 *          });
 *          //new WaitForSeconds(2);
 *
 *      }
 */
        //----------------------------------------------------------//
        //---------------- Kill live Channel-----------------------------//
        GetComponent <GameChannelManager>().KillIsChannel();
    }