/// <summary>
        /// Received on clients when server sends data.
        /// </summary>
        /// <param name="msg"></param>
        private void OnServerTransformSyncData(TransformSyncDataMessage msg)
        {
            //Old packet.
            if (IsOldPacket(_lastServerReceivedSequenceId, msg.SequenceId))
            {
                return;
            }

            _lastServerReceivedSequenceId = msg.SequenceId;

            int count = msg.Data.Count;

            for (int i = 0; i < count; i++)
            {
                /* Initially I tried caching the getcomponent calls but the performance difference
                 * couldn't be registered. At this time it's not worth creating the extra complexity
                 * for what might be a 1% fps difference. */
                if (NetworkIdentity.spawned.TryGetValue(msg.Data[i].NetworkIdentity, out NetworkIdentity ni))
                {
                    if (ni != null)
                    {
                        FlexNetworkTransformBase fntBase = ReturnFNTBaseOnNetworkIdentity(ni, msg.Data[i].ComponentIndex);
                        if (fntBase != null)
                        {
                            fntBase.ServerDataReceived(msg.Data[i]);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Received on server when client sends data.
        /// </summary>
        /// <param name="msg"></param>
        private void OnClientTransformSyncData(TransformSyncDataMessage msg)
        {
            //Have to check sequence id against the FNT sending.
            int count = msg.Data.Count;

            for (int i = 0; i < count; i++)
            {
                /* Initially I tried caching the getcomponent calls but the performance difference
                 * couldn't be registered. At this time it's not worth creating the extra complexity
                 * for what might be a 1% fps difference. */
                if (NetworkIdentity.spawned.TryGetValue(msg.Data[i].NetworkIdentity, out NetworkIdentity ni))
                {
                    if (ni != null)
                    {
                        FlexNetworkTransformBase fntBase = ReturnFNTBaseOnNetworkIdentity(ni, msg.Data[i].ComponentIndex);
                        if (fntBase != null)
                        {
                            //Skip if old packet.
                            if (IsOldPacket(fntBase.LastClientSequenceId, msg.SequenceId))
                            {
                                continue;
                            }

                            fntBase.SetLastClientSequenceIdInternal(msg.SequenceId);
                            fntBase.ClientDataReceived(msg.Data[i]);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Sends data to all or specified connection.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="datas"></param>
        /// <param name="reliable"></param>
        /// <param name="maxCollectionSize"></param>
        private void SendTransformSyncDatas(ushort sequenceId, bool toServer, NetworkConnection conn, List <TransformSyncData> datas, bool reliable)
        {
            int index       = 0;
            int bundleCount = (reliable) ? _reliableDataBundleCount : _unreliableDataBundleCount;
            int channel     = (reliable) ? 0 : 1;

            while (index < datas.Count)
            {
                int count = Mathf.Min(bundleCount, datas.Count - index);
                TransformSyncDataMessage msg = new TransformSyncDataMessage()
                {
                    SequenceId = sequenceId,
                    Data       = datas.GetRange(index, count)
                };

                if (toServer)
                {
                    NetworkClient.Send(msg, channel);
                }
                else
                {
                    //If no connection then send to all.
                    if (conn == null)
                    {
                        NetworkServer.SendToAll(msg, channel);
                    }
                    //Otherwise send to connection.
                    else
                    {
                        conn.Send(msg, channel);
                    }
                }
                index += count;
            }
        }