private void OnConnected(params object[] args) { SetConnectionStrength(ConnectionStrength.Connected); Strength = ConnectionStrength.Connected; OnConnectedEvent?.Invoke(); }
private void Awake() { Strength = ConnectionStrength.Offline; base.Awake(); DontDestroyOnLoad(gameObject); EventProcessor.AddInstructionParams(Inbound.ConnectionOK, OnConnected); EventProcessor.AddInstructionParams(Inbound.PingTest, PingResponse); EventProcessor.AddInstructionParams(Inbound.Crash, CrashRecovery); }
private void CrashRecovery(object[] obj) { SetConnectionStrength(ConnectionStrength.Connecting); Strength = ConnectionStrength.Connecting; }
private void OnConnectionFailed(object[] obj) { SetConnectionStrength(ConnectionStrength.Offline); Strength = ConnectionStrength.Offline; }
private void OnConnecting(params object[] args) { SetConnectionStrength(ConnectionStrength.Connecting); Strength = ConnectionStrength.Connecting; }
public void SetConnectionStrength(ConnectionStrength strength) { connectionStrengthImg.sprite = connectionStrengthIco[(byte)strength]; }
public void CheckConnection() { if (!PhotonNetwork.connected) { imgConnection.sprite = connVeryLow; lowConnectionCount++; if (GlobalVariables.bInGame) { //SceneManager.LoadScene("Menu"); PokerManager.instance.uiOthers.LoadMenu(); MessageManager.instance.Show(gameObject, "Terputus dari server", ButtonMode.OK, 1); } CancelInvoke("CheckConnection"); return; } int roundTripTime = PhotonNetwork.networkingPeer.RoundTripTime; txtSpeed.text = roundTripTime + " ms"; if (roundTripTime > 800) { connectionStrength = ConnectionStrength.NotPlayable; } else if (roundTripTime > 300) { connectionStrength = ConnectionStrength.VeryLow; } else if (roundTripTime > 200) { connectionStrength = ConnectionStrength.Low; } else if (roundTripTime > 150) { connectionStrength = ConnectionStrength.Normal; } else if (roundTripTime > 100) { connectionStrength = ConnectionStrength.Good; } else { connectionStrength = ConnectionStrength.Excellent; } if (connectionStrength == ConnectionStrength.NotPlayable) { PlayerPrefs.SetString("LastConnection", "low"); imgConnection.sprite = connVeryLow; lowConnectionCount++; } else if (connectionStrength == ConnectionStrength.VeryLow) { PlayerPrefs.SetString("LastConnection", "low"); imgConnection.sprite = connLow; lowConnectionCount++; } else if (connectionStrength == ConnectionStrength.Low || connectionStrength == ConnectionStrength.Normal) { PlayerPrefs.SetString("LastConnection", "normal"); imgConnection.sprite = connNormal; lowConnectionCount = 0; } else { PlayerPrefs.SetString("LastConnection", "normal"); imgConnection.sprite = connGood; lowConnectionCount = 0; } PlayerPrefs.Save(); if (lowConnectionCount >= 15 && GlobalVariables.bInGame) { GlobalVariables.bQuitOnNextRound = false; //StartCoroutine(PokerManager.instance.uiPause._LoadMenu ()); PokerManager.instance.uiOthers.LoadMenu(); PlayerPrefs.SetString(PrefEnum.PHOTON_ROOM_NAME.ToString(), PhotonNetwork.room.Name); PlayerPrefs.Save(); MenuPhotonNetworkManager.instance.Disconnect(); lowConnectionCount = 0; } }