using System;
using UnityEngine;
namespace FishNet.Managing.Transporting
{
    /// 
    /// When inherited from this may be used with the TransportManager to alter messages before they are sent and received.
    /// 
    public abstract class IntermediateLayer : MonoBehaviour
    {
        /// 
        /// TransportManager associated with this script.
        /// 
        public TransportManager TransportManager { get; private set; }
        /// 
        /// Called when data is received.
        /// 
        /// Original data.
        /// True if receiving from the server, false if from a client.
        /// Modified data.
        public abstract ArraySegment HandleIncoming(ArraySegment src, bool fromServer);
        /// 
        /// Called when data is sent.
        /// 
        /// Original data.
        /// True if sending to the server, false if to a client.
        /// Modified data.
        public abstract ArraySegment HandleOutoing(ArraySegment src, bool toServer);
        internal void InitializeOnce(TransportManager manager) => TransportManager = manager;
    }
}