void EnvelopeCallback(byte[] data, byte tag) { object obj = null; if (SelfAnalytical != null) { try { obj = SelfAnalytical(data, tag); }catch (Exception ex) { } } if (auto) { if (a_Dispatch != null) { a_Dispatch(data, tag, null); } } else { SocData soc = new SocData(); soc.data = data; soc.tag = tag; soc.obj = obj; lock (queue) queue.Enqueue(soc); } }
void Receive() { try { int len = client.Receive(buffer); if (Packaging) { var dat = envelope.Unpack(buffer, len); if (dat != null) { for (int i = 0; i < dat.Count; i++) { var item = dat[i]; EnvelopeCallback(item.data, item.type); } } } else { byte[] tmp = new byte[len]; for (int i = 0; i < len; i++) { tmp[i] = buffer[i]; } if (auto) { if (a_Dispatch != null) { a_Dispatch(tmp, 0, null); } } else { SocData soc = new SocData(); soc.data = tmp; lock (queue) queue.Enqueue(soc); } } } catch (Exception ex) { //if (ConnectFaild != null) // ConnectFaild(ex.StackTrace); } }
void EnvelopeCallback(byte[] data, byte tag) { if (auto) { if (MainDispatch != null) { MainDispatch(data, tag, endPoint); } } else { SocData soc = new SocData(); soc.data = data; soc.tag = tag; soc.obj = endPoint; queue.Enqueue(soc); } }
void EnvelopeCallback(byte[] data, byte tag, UdpLink iP) { if (auto) { if (MainDispatch != null) { MainDispatch(data, tag, iP); } } else { SocData soc = new SocData(); soc.data = data; soc.tag = tag; soc.obj = iP; lock (queue) queue.Enqueue(soc); } }