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); } }
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); }
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 (); } }
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); } }