protected void ReceivedDataSplit(object state) { while (this.isConnected) { byte[] receivedBytes = null; lock (SyncObject) { try { if (receivedRingBuffer.DataCount < 3) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[0] != 0xAA) { receivedRingBuffer.Clear(1); continue; } int len = DataConvert.Bytes_To_Ushort(new byte[2] { receivedRingBuffer[1], receivedRingBuffer[2] }) + 5; if (receivedRingBuffer.DataCount < len) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[len - 1] != 0xBB) { receivedRingBuffer.Clear(1); continue; } receivedBytes = new byte[len]; receivedRingBuffer.ReadFromRingBuffer(receivedBytes, 0, len); receivedRingBuffer.Clear(len); Monitor.Pulse(SyncObject); } catch { } } if (receivedBytes != null) { Msg.MessageObject msg = new Msg.MessageObject(receivedBytes); if (msg.CheckData()) { CallDelegateReceived(msg); } } } }
protected void ReceivedDataSplit(object state) { while (this.isConnected) { byte[] receivedBytes = null; lock (SyncObject) { try { if (receivedRingBuffer.DataCount < 6) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[0] != 170) { receivedRingBuffer.Clear(1); continue; } int len = receivedRingBuffer[2] + 5; if (receivedRingBuffer.DataCount < len) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[len - 1] != 187) { receivedRingBuffer.Clear(1); continue; } receivedBytes = new byte[len]; receivedRingBuffer.ReadFromRingBuffer(receivedBytes, 0, len); receivedRingBuffer.Clear(len); Monitor.Pulse(SyncObject); } catch { } } if (receivedBytes != null) { Msg.MessageObject_Child msg = new Msg.MessageObject_Child(receivedBytes); if (msg.Check()) { CallDelegateReceived(msg); } } } }
protected void ReceivedDataSplit(object state) { while (this.isConnected) { byte[] receivedBytes = null; lock (SyncObject) { try { if (receivedRingBuffer.DataCount < 4) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[0] != 8) { receivedRingBuffer.Clear(1); continue; } if (receivedRingBuffer[1] != 129) { receivedRingBuffer.Clear(1); continue; } receivedBytes = new byte[4]; receivedRingBuffer.ReadFromRingBuffer(receivedBytes, 0, 4); receivedRingBuffer.Clear(4); Monitor.Pulse(SyncObject); } catch { } } if (receivedBytes != null) { Msg.MessageObject msg = new Msg.MessageObject(receivedBytes); CallDelegateReceived(msg); } } }
protected void ReceivedDataSplit(object state) { while (this.isConnected) { byte[] receivedBytes = null; lock (SyncObject) { try { if (receivedRingBuffer.DataCount < 8) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[0] != 64) { receivedRingBuffer.Clear(1); continue; } if (receivedRingBuffer[7] != 13) { receivedRingBuffer.Clear(1); continue; } int len = 0; switch (receivedRingBuffer[1]) { case 4: case 7: case 8: case 9: case 10: case 11: case 13: case 16: len = (ushort)(((0xff & receivedRingBuffer[4]) << 8) + (0xff & receivedRingBuffer[3])); break; } if (len != 0) { if (receivedRingBuffer.DataCount < len + 13) { Monitor.Wait(SyncObject); continue; } if (receivedRingBuffer[8] != 62) { receivedRingBuffer.Clear(1); continue; } if (receivedRingBuffer[len + 12] != 13) { receivedRingBuffer.Clear(1); continue; } } receivedBytes = new byte[len == 0?8:(len + 13)]; receivedRingBuffer.ReadFromRingBuffer(receivedBytes, 0, receivedBytes.Length); receivedRingBuffer.Clear(receivedBytes.Length); Monitor.Pulse(SyncObject); } catch { } } if (receivedBytes != null) { Msg.MessageObject msg = new Msg.MessageObject(receivedBytes); if (msg.CheckData()) { CallDelegateReceived(msg); } } } }