/// <summary> /// 发送线程 /// </summary> private void JustServiceSendThread() { JustArgs args = null; JustAdapter adapter = this.mAdapter; while (true) { Queue <JustArgs> argsQueue = this.argsQueue; args = null; if (argsQueue.Count > 0) { args = argsQueue.Dequeue(); } if (args == null) { mSendEvent.WaitOne(); continue; //args = argsQueue.Dequeue(); } adapter.mJustClientInterface.LowLevelSend(mAdapter, args); JustEventInterface JustEvent = adapter.mJustEventInterface; if (JustEvent != null) { JustEvent.OnSendEvent(adapter, args); } } }
/// <summary> /// 接收线程 /// </summary> private void JustServiceRecvThread() { byte[] buffer = null; JustAdapter adapter = this.mAdapter; while (true) { buffer = adapter.mJustClientInterface.LowLevelRecv(mAdapter); JustEventInterface JustEvent = adapter.mJustEventInterface; if (JustEvent != null) { JustEvent.OnRecvEvent(adapter, buffer); //TODO:根据返回值,决定是否需要继续接收 } } }
public JustAdapter(JustClientInterface mJustClientInterface, JustEventInterface mJustEventInterface, object TAG) : this(mJustClientInterface, mJustEventInterface) { this.TAG = TAG; }
public JustAdapter(JustClientInterface mJustClientInterface, JustEventInterface mJustEventInterface) { this.mJustClientInterface = mJustClientInterface; this.mJustEventInterface = mJustEventInterface; this.TAG = null; }