コード例 #1
0
        public byte[] ToByteArray()
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(Encoding.ASCII.GetBytes(PacketType));
            buffer.WriteInteger(TransferID);
            return(buffer.ToArray());
        }
コード例 #2
0
        public byte[] ToByteArray()
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(Encoding.ASCII.GetBytes(PacketType));
            buffer.WriteString(PacketText);

            return(buffer.ToArray());
        }
コード例 #3
0
        public byte[] ToByteArray()
        {
            byte[]       data   = new byte[8];
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(Encoding.ASCII.GetBytes(PacketType));
            buffer.WriteBytes(BitConverter.GetBytes(PacketNumber));
            buffer.WriteBytes(BitConverter.GetBytes(TransferID));
            return(buffer.ToArray());
        }
コード例 #4
0
        /// <summary>
        /// Creates a ScoutResponsePacket given a NetworkDevice structure
        /// </summary>
        /// <param name="device"></param>
        public ScoutResponsePacket(NetworkDevice device)
        {
            PacketType = "_SCA";
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteString(device.Name);
            buffer.WriteByte((byte)device.Type);

            PacketData = buffer.ToArray();
        }
コード例 #5
0
        public TransferRequestPacket(LocalFileStructure fStruct, int localID)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger(localID);
            buffer.WriteLong(fStruct.FileSize);
            buffer.WriteString(fStruct.FileName);
            buffer.WriteString(fStruct.FileExtension);
            PacketData = buffer.ToArray();
            PacketType = "_TFR";
        }
コード例 #6
0
        /// <summary>
        /// Serializes the packet into a byte array for sending
        /// </summary>
        /// <returns></returns>
        public byte[] ToByteArray()
        {
            if (PacketData == null)
            {
                return(null);
            }

            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(Encoding.ASCII.GetBytes(PacketType));
            buffer.WriteBytes(PacketData);
            return(buffer.ToArray());
        }
コード例 #7
0
        private void ProcessFinishedFile()
        {
            // Create the byte buffer and include it in the OnTransferFinished event
            PacketBuffer buffer = new PacketBuffer();

            for (int i = 0; i < ReceivedChunks.Count; i++)
            {
                buffer.WriteBytes(ReceivedChunks[i].Data);
            }

            byte[] fileBuffer = buffer.ToArray();

            OnTransferFinished?.Invoke(null, new InboundTransferEventArgs(TransferID, true, fileBuffer, IncomingFileStructure));

            fileBuffer     = null;
            ReceivedChunks = null;
        }