コード例 #1
0
ファイル: USocket.cs プロジェクト: takaaptech/Islands-World
        public void connectAsync(NetCallback onConnectStateChgCallback)
        {
            try
            {
                isActive = false;
                this.onConnectStateChgCallback = onConnectStateChgCallback;
                if (ipe == null)
                {
                    onConnectStateChg(false, Errors.IPEndPointIsNull);
                    return;
                }

                mSocket.BeginConnect(ipe, (AsyncCallback)connectCallback, this);
                if (connectTimeout != null)
                {
                    connectTimeout.Dispose();
                    connectTimeout = null;
                }
                connectTimeout = TimerEx.schedule((TimerCallback)connectTimeOut, null, timeoutMSec);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
コード例 #2
0
ファイル: USocket.cs プロジェクト: coolape/mibao
		public void connectAsync (NetCallback callback, NetCallback offLineCallback)
		{
			if (ipe == null) {
				callback (this, false);
				return;
			}
			this.offLineCallback = offLineCallback;
			IsConnectionSuccessful = false;
			connectCallbackFunc = callback;

			mSocket.BeginConnect (ipe, (AsyncCallback)connectCallback, this);
            if(connectTimeout != null) {
                connectTimeout.Dispose();
                connectTimeout = null;
            }
            connectTimeout = TimerEx.schedule((TimerCallback)connectTimeOut, null, timeoutMSec);
        }
コード例 #3
0
ファイル: USocket.cs プロジェクト: coolape/mibao
		public void SendAsync (byte[] data)
		{
			try {
				if (data == null)
					return;
				// isOpen始发送Number据到远程设备.
				if (this.timeoutCheckTimer == null) {
					this.timeoutCheckTimer = TimerEx.schedule ((TimerCallback)sendTimeOut, null, timeoutMSec);
				}
				mSocket.BeginSend (data, 0, data.Length, 0,
					(AsyncCallback)SendCallback, this);
			} catch (System.Exception e) {
				Debug.LogError ("socket:" + e);
				if (offLineCallback != null) {
					offLineCallback (this, null);
				}
				close ();
			}
		}
コード例 #4
0
ファイル: USocket.cs プロジェクト: takaaptech/Islands-World
        public void SendAsync(byte[] data)
        {
            try
            {
                if (data == null)
                {
                    return;
                }
                // isOpen始发送Number据到远程设备.
                if (this.timeoutCheckTimer == null)
                {
                    this.timeoutCheckTimer = TimerEx.schedule((TimerCallback)sendTimeOut, null, timeoutMSec);
                }

                mSocket.BeginSend(data, 0, data.Length, 0,
                                  (AsyncCallback)SendCallback, this);
            }
            catch (Exception e)
            {
                Debug.LogError("socket:" + e);
                onConnectStateChg(false, Errors.sendAsynException);
            }
        }