/// <summary> /// Used to clean up the target composer from memory /// </summary> /// <param name="composer">The composer that has completed</param> protected void ComposerCompleted(FacepunchP2PPacketComposer composer) { #if DEEP_LOGGING Logging.BMSLog.Log($"<<<<<<<<<<<<<<<<<<<<<<<<<<< CONFIRMING: {composer.Frame.UniqueId}"); #endif lock (pendingComposers) { pendingComposers.Remove(composer); } }
/// <summary> /// Sends data to the server /// </summary> /// <param name="frame">Data to send</param> /// <param name="reliable">Send reliable (slow) or unreliable (fast)</param> public override void Send(FrameStream frame, bool reliable = false) { var composer = new FacepunchP2PPacketComposer(this, Server, frame, reliable); // If this message is reliable then make sure to keep a reference to the composer // so that there are not any run-away threads if (reliable) { // Use the completed event to clean up the object from memory composer.completed += ComposerCompleted; pendingComposers.Add(composer); } }