コード例 #1
0
 internal static void ConnectAsync()
 {
     if (!VRCTools.ModPrefs.GetBool("vrctools", "remoteauthcheck"))
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client doesn't allow auth");
     }
     else if (State != ConnectionState.DISCONNECTED)
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client is not disconnected");
     }
     else if (client != null && client.autoReconnect)
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client already exist and is tagged as auto-reconnecting");
     }
     else
     {
         if (client == null)
         {
             client = new Client(SERVER_ADDRESS, SERVER_PORT, VRCMODNW_VERSION);
             if (instance == null)
             {
                 instance = new VRCModNetworkManager();
             }
             client.SetConnectionListener(instance);
             Thread modsCheckerThread = new Thread(() => ModCheckThread());
             modsCheckerThread.Name         = "Mod Check Thread";
             modsCheckerThread.IsBackground = true;
             modsCheckerThread.Start();
         }
         State = ConnectionState.CONNECTING;
         client.StartConnection();
     }
 }
コード例 #2
0
 internal static void ConnectAsync()
 {
     if (State != ConnectionState.DISCONNECTED)
     {
         VRCModLogger.Log("[VRCModNetworkManager] Trying to connect to server, but client is not disconnected");
     }
     else if (client != null && client.autoReconnect)
     {
         VRCModLogger.Log("[VRCModNetworkManager] Trying to connect to server, but client already exist and is tagged as auto-reconnecting");
     }
     else
     {
         if (client == null)
         {
             client = new Client(SERVER_ADDRESS, SERVER_PORT, VRCMODNW_VERSION);
             if (instance == null)
             {
                 instance = new VRCModNetworkManager();
             }
             client.SetConnectionListener(instance);
             if (modsCheckerThread == null)
             {
                 modsCheckerThread = new Thread(ModCheckThread)
                 {
                     Name         = "Mod Check Thread",
                     IsBackground = true
                 };
                 modsCheckerThread.Start();
             }
         }
         State = ConnectionState.CONNECTING;
         client.StartConnection();
     }
 }
コード例 #3
0
 public override void OnUpdate()
 {
     if (!Initialized)
     {
         return;
     }
     VRCModNetworkManager.Update();
     VRCModNetworkStatus.Update();
     //ModdedUsersManager.Update();
 }
コード例 #4
0
        private IEnumerator Setup()
        {
            // TODO check for updates

            MelonModLogger.Log("Initialising VRCModNetwork");

            MelonModLogger.Log("Overwriting login button event");
            VRCUiPageAuthentication loginPage = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>().FirstOrDefault((page) => page.gameObject.name == "LoginUserPass");

            MelonModLogger.Log("loginPage: " + loginPage);
            if (loginPage != null)
            {
                Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>();
                if (loginButton != null)
                {
                    ButtonClickedEvent bce = loginButton.onClick;
                    loginButton.onClick = new ButtonClickedEvent();
                    loginButton.onClick.AddListener(new Action(() =>
                    {
                        VRCModNetworkManager.SetCredentials(Uri.EscapeDataString(loginPage.loginUserName.field_String_2) + ":" + Uri.EscapeDataString(loginPage.loginPassword.field_String_2));
                        bce?.Invoke();
                    }));
                }
                else
                {
                    MelonModLogger.Log("Unable to find login button in login page");
                }
            }

            try
            {
                VRCModNetworkStatus.Setup();
                VRCModNetworkLogin.SetupVRCModNetworkLoginPage();
                //ModdedUsersManager.Init();
            }
            catch (Exception e)
            {
                MelonModLogger.LogError(e.ToString());
            }

            MelonModLogger.Log("Injecting VRCModNetwork login page");
            VRCModNetworkLogin.InjectVRCModNetworkLoginPage();

            MelonModLogger.Log("Connecting");
            yield return(VRCModNetworkManager.ConnectInit());

            MelonModLogger.Log("VRCModNetwork sucessfully initialized!");

            Initialized = true;
        }