Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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));
        }
Example #4
0
        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);
        }