void MakePacket(int packetID, object str) { DefinedStructure.PacketInfo packet; packet._id = packetID; packet._data = new byte[1024]; byte[] temp = ConvertPacket.StructureToByteArray(str); for (int n = 0; n < temp.Length; n++) { packet._data[n] = temp[n]; } packet._totalSize = temp.Length; _data = ConvertPacket.StructureToByteArray(packet); _dataSize = _data.Length; }
public void AddFromQueue(Queue <PacketClass> fromClient) { if (_socketList.Count != 0) { for (int n = 0; n < _socketList.Count; n++) { byte[] buffer; int recvLen; if (_socketList[n] != null && _socketList[n].ReceiveBuffer(out buffer, out recvLen)) { DefinedStructure.PacketInfo pInfo = new DefinedStructure.PacketInfo(); pInfo = (DefinedStructure.PacketInfo)ConvertPacket.ByteArrayToStructure(buffer, pInfo.GetType(), recvLen); PacketClass packet = new PacketClass(pInfo._id, pInfo._data, pInfo._totalSize, n, _socketList[n]._UUID); fromClient.Enqueue(packet); } } } }
public object Convert(Type type) { return(ConvertPacket.ByteArrayToStructure(_data, type, _dataSize)); }