Exemplo n.º 1
0
        private static void ProcessTFA(IPEndPoint ep, TransferAcceptPacket tap)
        {
            int senderID = tap.GetSenderTransferID();

            if (ActiveOutboundTransferProcess != null)
            {
                ActiveOutboundTransferProcess.ReceivePacket(tap);
            }
        }
Exemplo n.º 2
0
        private static void ProcessFileTransferRequest(IPEndPoint ep, TransferRequestPacket packet)
        {
            LocalFileStructure fStruct = packet.GetFileStructure();

            if (fStruct == null)
            {
                // Send error
                return;
            }
            // Check that its ok

            //if(fStruct.FileSize > 500000000) // Refuse if over 500mb
            //{
            //    // Send transfer refusal

            //    return;
            //}


            // set up

            int slot = GetAviableInboundTransferProcessID();

            if (slot == -1)
            {
                // Send transfer refusal. No slots aviable
                return;
            }

            // Create a new inbound process
            ActiveInboundTransferProcesses[slot] = new InboundTransferProcess(packet.GetSenderTransferID(),
                                                                              fStruct,
                                                                              ep,
                                                                              _fileHandler);

            ActiveInboundTransferProcesses[slot].OnTransferFinished += InboundTransferFinished;

            // Send Transfer acceptal
            TransferAcceptPacket ta = new TransferAcceptPacket(slot, packet.GetSenderTransferID());

            NetComm.SendByteArray(ta.ToByteArray(), ep);
        }