public void ConnectAsync(NpCloudSocketType type, string url, int timeOut, Action <bool> result, object option = null) { if (this.mCloudType != NpCloud.Type.None) { result(true); return; } this.mIsConnectAsync = false; this.mConnectAsyncAction = result; Action connect = delegate() { Action <bool, Exception> result2 = delegate(bool flg, Exception e) { this.ConnectResultAction(flg, e, result); }; NpCloudSocketSystem.GetInstance().ConnectAsync(timeOut, result2, option); this.mCloudType = NpCloud.Type.Connecting; }; if (!this.ConnectCore(type, url, connect)) { this.mIsConnectAsync = true; this.mIsConnectAsyncResult = false; } }
private bool ConnectCore(NpCloudSocketType type, string url, Action connect) { bool result; try { this.mHandlerInstance.Active(true); this.mErrorCode = 0; this.mErrorMsg = string.Empty; this.mCloudType = NpCloud.Type.None; NpCloudSocketSystem.CreateInstance(url, type, this.mHashKey); connect(); if (this.mCloudType == NpCloud.Type.Error) { result = false; } else { result = true; } } catch (NpCloudException errorData) { this.SetErrorData(errorData); this.Exit(this.mErrorCode, this.mErrorMsg); result = false; } catch (Exception errorData2) { this.SetErrorData(errorData2); this.Exit(this.mErrorCode, this.mErrorMsg); result = false; } return(result); }
public bool Connect(NpCloudSocketType type, string url, int timeOut, object option = null) { if (this.mCloudType != NpCloud.Type.None) { return(true); } Action connect = delegate() { NpCloudSocketSystem instance = NpCloudSocketSystem.GetInstance(); bool flag = false; global::Debug.Log("npCloudSocketSystem " + instance); if (instance != null) { flag = instance.Connect(timeOut, option); } if (flag) { this.mCloudType = NpCloud.Type.Idle; } else { this.mCloudType = NpCloud.Type.Error; } }; return(this.ConnectCore(type, url, connect)); }
private void Exit(short exitCode, string message) { this.mCloudType = NpCloud.Type.None; this.mHandlerInstance.Active(false); Action exitAction = delegate() { this.ExitAction(exitCode, message); }; NpCloudSocketSystem.DeleteInstance(exitAction); }