public void StartConnection(Action after) { this.doAfterFetch = after; MasterInfo masterInfo = MasterInfo.Fetch(); if (masterInfo == null) { if (GameTracker.mgcache0 == null) { GameTracker.mgcache0 = new Action <string>(MsgController.ShowMsg); } SyncContext.RunOnUI <string>(GameTracker.mgcache0, SFST.T.STP_Request_Timeout); return; } this.client = new Client(masterInfo.REDIRECT, 100); this.client.rec.eventSystem.RegisterListener(new EventListener <ClientAuthedEvent>(delegate(ClientAuthedEvent e) { SyncContext.RunOnUI(after); })); this.client.rec.eventSystem.RegisterListener(new EventListener <InitialTimeoutEvent>(delegate(InitialTimeoutEvent e) { if (GameTracker.mgcache1 == null) { GameTracker.mgcache1 = new Action <string>(MsgController.ShowMsg); } SyncContext.RunOnUI <string>(GameTracker.mgcache1, SFST.T.STP_Request_Timeout); })); this.client.rec.eventSystem.RegisterListener(new EventListener <PacketReceivedEvent>(delegate(PacketReceivedEvent e) { if (e.receivedPacket.Is <ServerErrorPacket>()) { ServerErrorPacket serverErrorPacket = e.receivedPacket.ToTargetPacket <ServerErrorPacket>(); if (serverErrorPacket.Error == "AUTHENTICATION") { SyncContext.RunOnUI(delegate { MsgController.ShowMsg(SFST.T.STP_Old_Credentials); Sharing.sharing.downloadMenu.SetActive(false); this.client.rec.Delete(); this.client.CleanCreds(); }); this.StartConnection(delegate { if (GameTracker.mgcache2 == null) { GameTracker.mgcache2 = new Action <string>(MsgController.ShowMsg); } SyncContext.RunOnUI <string>(GameTracker.mgcache2, SFST.T.STP_Reconnected); }); } } })); }
public bool CheckConnection() { if (Application.internetReachability == NetworkReachability.NotReachable) { MsgController.ShowMsg(SFST.T.Sharing_No_Connection); return(false); } this.latestInfo = MasterInfo.Fetch(); if (this.latestInfo == null) { if (Sharing.mgcache0 == null) { Sharing.mgcache0 = new Action <string>(MsgController.ShowMsg); } SyncContext.RunOnUI <string>(Sharing.mgcache0, SFST.T.STP_Request_Timeout); return(false); } int num = VersionHolder.SharingVersion.CompareVersion(this.latestInfo.Version.Sharing.Client); int num2 = VersionHolder.ProtocolVersion.CompareVersion(this.latestInfo.Version.Sharing.Protocol); if (num == -1) { MsgController.ShowMsg(SFST.T.Sharing_Old_Version); return(false); } if (num == 1) { MsgController.ShowMsg(SFST.T.Sharing_New_Version); return(false); } if (num2 == -1) { MsgController.ShowMsg(SFST.T.Sharing_Old_Protocol); return(false); } if (num2 == 1) { MsgController.ShowMsg(SFST.T.Sharing_New_Protocol); return(false); } return(true); }