public ReceiveViaManualPacketsOperation(NetMessageViaManualPacketsHeader transferHeader, INetworkInterfaceConnection source, SessionInterface sessionInterface) : base(sessionInterface, source, transferHeader.TransferId) { _transferInfo = transferHeader; if (_transferInfo.DataSize > Transfers.MAX_TRANSFER_SIZE) { return; } _data = new byte[_transferInfo.DataSize]; _paquetStates = new PacketState[_transferInfo.PacketCount]; _remainingUnreceivedPaquets = _transferInfo.PacketCount; }
protected override IEnumerator ExecuteRoutine() { if (!PreExecuteRoutine()) { yield break; } //////////////////////////////////////////////////////////////////////////////////////// // Send header to destination (contains essential details about the transfer) //////////////////////////////////////////////////////////////////////////////////////// NetMessageViaManualPacketsHeader header = new NetMessageViaManualPacketsHeader() { TransferId = _transferId, DataSize = _data.Length, PacketCount = _remainingUnacknowledgedPackets, Description = Description }; _sessionInterface.SendNetMessage(header, _connection); //////////////////////////////////////////////////////////////////////////////////////// // Update Transfer //////////////////////////////////////////////////////////////////////////////////////// _sessionInterface.RegisterNetMessageReceiver <NetMessagePacketACK>(OnPacketAcknowledged); while (_remainingUnacknowledgedPackets > 0) { // reset 'packetsSentThisFrame'. This value will ensure we don't send to many packets per second to our sessionInterface s_currentUnityFrame.Set(Time.frameCount); if (s_currentUnityFrame.ClearDirty()) { s_packetsSentThisFrame = 0; } // Update UpdateDataTransfer(); // wait a frame yield return(null); if (!IsRunning) { yield break; } } TerminateWithSuccess(); }