FinishMessage() public method

This fills out the size header of a message begun with StartMessage(), so that it can be send using Send() functions.

public FinishMessage ( ) : void
return void
Example #1
0
 private void PostInternalMessage(short msgType)
 {
     NetworkWriter writer = new NetworkWriter();
     writer.StartMessage(msgType);
     writer.FinishMessage();
     this.PostInternalMessage(writer.AsArray(), 0);
 }
Example #2
0
 internal void InvokeHandlerOnClient(short msgType, MessageBase msg, int channelId)
 {
     NetworkWriter writer = new NetworkWriter();
     writer.StartMessage(msgType);
     msg.Serialize(writer);
     writer.FinishMessage();
     this.InvokeBytesOnClient(writer.AsArray(), channelId);
 }
Example #3
0
        public bool Send(short msgType, MessageBase msg)
        {
            // build the stream
            s_SendWriter.StartMessage(msgType);
            msg.Serialize(s_SendWriter);
            s_SendWriter.FinishMessage();

            numMsgsOut += 1;
            return(SendWriter(s_SendWriter));
        }
        // called by the server, to bypass network
        internal void InvokeHandlerOnClient(short msgType, MessageBase msg, int channelId)
        {
            // write the message to a local buffer
            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(msgType);
            msg.Serialize(writer);
            writer.FinishMessage();

            InvokeBytesOnClient(writer.AsArray(), channelId);
        }
Example #5
0
        internal void UNetUpdate()
        {
            uint num = 0;

            for (int i = 0; i < this.m_NetworkBehaviours.Length; i++)
            {
                int dirtyChannel = this.m_NetworkBehaviours[i].GetDirtyChannel();
                if (dirtyChannel != -1)
                {
                    num |= ((uint)1) << dirtyChannel;
                }
            }
            if (num != 0)
            {
                for (int j = 0; j < NetworkServer.numChannels; j++)
                {
                    if ((num & (((int)1) << j)) != 0)
                    {
                        s_UpdateWriter.StartMessage(8);
                        s_UpdateWriter.Write(this.netId);
                        bool flag = false;
                        for (int k = 0; k < this.m_NetworkBehaviours.Length; k++)
                        {
                            short            position   = s_UpdateWriter.Position;
                            NetworkBehaviour behaviour2 = this.m_NetworkBehaviours[k];
                            if (behaviour2.GetDirtyChannel() != j)
                            {
                                behaviour2.OnSerialize(s_UpdateWriter, false);
                            }
                            else
                            {
                                if (behaviour2.OnSerialize(s_UpdateWriter, false))
                                {
                                    behaviour2.ClearAllDirtyBits();
                                    NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 8, behaviour2.GetType().Name, 1);
                                    flag = true;
                                }
                                if (((s_UpdateWriter.Position - position) > NetworkServer.maxPacketSize) && LogFilter.logWarn)
                                {
                                    Debug.LogWarning(string.Concat(new object[] { "Large state update of ", s_UpdateWriter.Position - position, " bytes for netId:", this.netId, " from script:", behaviour2 }));
                                }
                            }
                        }
                        if (flag)
                        {
                            s_UpdateWriter.FinishMessage();
                            NetworkServer.SendWriterToReady(base.gameObject, s_UpdateWriter, j);
                        }
                    }
                }
            }
        }
        void SendMsg(Operation op, int itemIndex, T item)
        {
            if (m_Behaviour == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("SyncList not initialized");
                }
                return;
            }

            var uv = m_Behaviour.GetComponent <NetworkIdentity>();

            if (uv == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("SyncList no NetworkIdentity");
                }
                return;
            }

            if (!uv.isServer)
            {
                // object is not spawned yet, so no need to send updates.
                return;
            }

            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(MsgType.SyncList);
            writer.Write(uv.netId);
            writer.WritePackedUInt32((uint)m_CmdHash);
            writer.Write((byte)op);
            writer.WritePackedUInt32((uint)itemIndex);
            SerializeItem(writer, item);
            writer.FinishMessage();

            NetworkServer.SendWriterToReady(uv.gameObject, writer, m_Behaviour.GetNetworkChannel());

#if UNITY_EDITOR
            UnityEditor.NetworkDetailStats.IncrementStat(
                UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
                MsgType.SyncList, op.ToString(), 1);
#endif

            // ensure it is invoked on host
            if (m_Behaviour.isServer && m_Behaviour.isClient && m_Callback != null)
            {
                m_Callback.Invoke(op, itemIndex);
            }
        }
Example #7
0
        internal void UNetUpdate()
        {
            uint num = 0u;

            for (int i = 0; i < m_NetworkBehaviours.Length; i++)
            {
                NetworkBehaviour networkBehaviour = m_NetworkBehaviours[i];
                int dirtyChannel = networkBehaviour.GetDirtyChannel();
                if (dirtyChannel != -1)
                {
                    num = (uint)((int)num | (1 << dirtyChannel));
                }
            }
            if (num == 0)
            {
                return;
            }
            for (int j = 0; j < NetworkServer.numChannels; j++)
            {
                if (((int)num & (1 << j)) == 0)
                {
                    continue;
                }
                s_UpdateWriter.StartMessage(8);
                s_UpdateWriter.Write(netId);
                bool flag = false;
                for (int k = 0; k < m_NetworkBehaviours.Length; k++)
                {
                    short            position          = s_UpdateWriter.Position;
                    NetworkBehaviour networkBehaviour2 = m_NetworkBehaviours[k];
                    if (networkBehaviour2.GetDirtyChannel() != j)
                    {
                        networkBehaviour2.OnSerialize(s_UpdateWriter, initialState: false);
                        continue;
                    }
                    if (networkBehaviour2.OnSerialize(s_UpdateWriter, initialState: false))
                    {
                        networkBehaviour2.ClearAllDirtyBits();
                        flag = true;
                    }
                    if (s_UpdateWriter.Position - position > NetworkServer.maxPacketSize && LogFilter.logWarn)
                    {
                        Debug.LogWarning("Large state update of " + (s_UpdateWriter.Position - position) + " bytes for netId:" + netId + " from script:" + networkBehaviour2);
                    }
                }
                if (flag)
                {
                    s_UpdateWriter.FinishMessage();
                    NetworkServer.SendWriterToReady(base.gameObject, s_UpdateWriter, j);
                }
            }
        }
 protected void SendEventInternal(NetworkWriter writer, int channelId, string eventName)
 {
     if (!NetworkServer.active)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("SendEvent no server?");
         }
         return;
     }
     writer.FinishMessage();
     NetworkServer.SendWriterToReady(base.gameObject, writer, channelId);
 }
 protected void SendRPCInternal(NetworkWriter writer, int channelId, string rpcName)
 {
     if (!this.isServer)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("ClientRpc call on un-spawned object");
         }
         return;
     }
     writer.FinishMessage();
     NetworkServer.SendWriterToReady(base.gameObject, writer, channelId);
 }
Example #10
0
        internal bool SendFragmentBytes(byte[] bytes, int bytesToSend)
        {
            int num = 0;

            while (bytesToSend > 0)
            {
                int    num2  = Math.Min(bytesToSend, m_MaxPacketSize - 32);
                byte[] array = new byte[num2];
                Array.Copy(bytes, num, array, 0, num2);
                s_FragmentWriter.StartMessage(17);
                s_FragmentWriter.Write((byte)0);
                s_FragmentWriter.WriteBytesFull(array);
                s_FragmentWriter.FinishMessage();
                SendWriter(s_FragmentWriter);
                num         += num2;
                bytesToSend -= num2;
            }
            s_FragmentWriter.StartMessage(17);
            s_FragmentWriter.Write((byte)1);
            s_FragmentWriter.FinishMessage();
            SendWriter(s_FragmentWriter);
            return(true);
        }
 protected void SendTargetRPCInternal(NetworkConnection conn, NetworkWriter writer, int channelId, string rpcName)
 {
     if (!this.isServer)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("TargetRpc call on un-spawned object");
         }
     }
     else
     {
         writer.FinishMessage();
         conn.SendWriter(writer, channelId);
     }
 }
        void SendTransform()
        {
            if (!HasMoved() || ClientScene.readyConnection == null)
            {
                return;
            }

            m_LocalTransformWriter.StartMessage(SkeletonMsg);
            m_LocalTransformWriter.Write(netId);
            SerializeModeTransform(m_LocalTransformWriter);

            m_LocalTransformWriter.FinishMessage();

            ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
        }
Example #13
0
        protected void SendRPCInternal(NetworkWriter writer, int channelId, string rpcName)
        {
            // This cannot use NetworkServer.active, as that is not specific to this object.
            if (!isServer)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("ClientRpc call on un-spawned object");
                }
                return;
            }

            writer.FinishMessage();
            NetworkServer.SendWriterToReady(gameObject, writer, channelId);
        }
Example #14
0
        private void SendTransform()
        {
            if (HasMoved() && ClientScene.readyConnection != null)
            {
                m_LocalTransformWriter.StartMessage(6);
                m_LocalTransformWriter.Write(base.netId);
                switch (transformSyncMode)
                {
                case TransformSyncMode.SyncNone:
                    return;

                case TransformSyncMode.SyncTransform:
                    SerializeModeTransform(m_LocalTransformWriter);
                    break;

                case TransformSyncMode.SyncRigidbody3D:
                    SerializeMode3D(m_LocalTransformWriter);
                    break;

                case TransformSyncMode.SyncRigidbody2D:
                    SerializeMode2D(m_LocalTransformWriter);
                    break;

                case TransformSyncMode.SyncCharacterController:
                    SerializeModeCharacterController(m_LocalTransformWriter);
                    break;
                }
                if (m_RigidBody3D != null)
                {
                    m_PrevPosition = m_RigidBody3D.position;
                    m_PrevRotation = m_RigidBody3D.rotation;
                    m_PrevVelocity = m_RigidBody3D.velocity.sqrMagnitude;
                }
                else if (m_RigidBody2D != null)
                {
                    m_PrevPosition   = m_RigidBody2D.position;
                    m_PrevRotation2D = m_RigidBody2D.rotation;
                    m_PrevVelocity   = m_RigidBody2D.velocity.sqrMagnitude;
                }
                else
                {
                    m_PrevPosition = base.transform.position;
                    m_PrevRotation = base.transform.rotation;
                }
                m_LocalTransformWriter.FinishMessage();
                ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
            }
        }
Example #15
0
 protected void SendEventInternal(NetworkWriter writer, int channelId, string eventName)
 {
     if (!NetworkServer.active)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("SendEvent no server?");
         }
     }
     else
     {
         writer.FinishMessage();
         NetworkServer.SendWriterToReady(base.gameObject, writer, channelId);
         NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 7, eventName, 1);
     }
 }
Example #16
0
 protected void SendRPCInternal(NetworkWriter writer, int channelId, string rpcName)
 {
     if (!this.isServer)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("ClientRpc call on un-spawned object");
         }
     }
     else
     {
         writer.FinishMessage();
         NetworkServer.SendWriterToReady(base.gameObject, writer, channelId);
         NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 2, rpcName, 1);
     }
 }
Example #17
0
        protected void SendTargetRPCInternal(NetworkConnection conn, NetworkWriter writer, int channelId, string rpcName)
        {
            // This cannot use NetworkServer.active, as that is not specific to this object.
            if (!isServer)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("TargetRpc call on un-spawned object");
                }
                return;
            }

            writer.FinishMessage();

            conn.SendWriter(writer, channelId);
        }
Example #18
0
 private void SendMsg(SyncList <T> .Operation op, int itemIndex, T item)
 {
     if ((Object)this.m_Behaviour == (Object)null)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Debug.LogError((object)"SyncList not initialized");
     }
     else
     {
         NetworkIdentity component = this.m_Behaviour.GetComponent <NetworkIdentity>();
         if ((Object)component == (Object)null)
         {
             if (!LogFilter.logError)
             {
                 return;
             }
             Debug.LogError((object)"SyncList no NetworkIdentity");
         }
         else
         {
             if (!component.isServer)
             {
                 return;
             }
             NetworkWriter writer = new NetworkWriter();
             writer.StartMessage((short)9);
             writer.Write(component.netId);
             writer.WritePackedUInt32((uint)this.m_CmdHash);
             writer.Write((byte)op);
             writer.WritePackedUInt32((uint)itemIndex);
             this.SerializeItem(writer, item);
             writer.FinishMessage();
             NetworkServer.SendWriterToReady(component.gameObject, writer, this.m_Behaviour.GetNetworkChannel());
             NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, (short)9, op.ToString(), 1);
             if (!this.m_Behaviour.isServer || !this.m_Behaviour.isClient || this.m_Callback == null)
             {
                 return;
             }
             this.m_Callback(op, itemIndex);
         }
     }
 }
        protected void SendEventInternal(NetworkWriter writer, int channelId, string eventName)
        {
            if (!NetworkServer.active)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("SendEvent no server?");
                }
                return;
            }

            writer.FinishMessage();
            NetworkServer.SendWriterToReady(gameObject, writer, channelId);

#if UNITY_EDITOR
            Profiler.IncrementStatOutgoing(MsgType.SyncEvent, eventName);
#endif
        }
Example #20
0
        internal void UNetUpdate()
        {
            uint num = 0;

            for (int i = 0; i < this.m_NetworkBehaviours.Length; i++)
            {
                int dirtyChannel = this.m_NetworkBehaviours[i].GetDirtyChannel();
                if (dirtyChannel != -1)
                {
                    num |= ((uint)1) << dirtyChannel;
                }
            }
            if (num != 0)
            {
                for (int j = 0; j < NetworkServer.numChannels; j++)
                {
                    if ((num & (((int)1) << j)) != 0)
                    {
                        s_UpdateWriter.StartMessage(8);
                        s_UpdateWriter.Write(this.netId);
                        bool flag = false;
                        for (int k = 0; k < this.m_NetworkBehaviours.Length; k++)
                        {
                            NetworkBehaviour behaviour2 = this.m_NetworkBehaviours[k];
                            if (behaviour2.GetDirtyChannel() != j)
                            {
                                behaviour2.OnSerialize(s_UpdateWriter, false);
                            }
                            else if (behaviour2.OnSerialize(s_UpdateWriter, false))
                            {
                                behaviour2.ClearAllDirtyBits();
                                NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 8, behaviour2.GetType().Name, 1);
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            s_UpdateWriter.FinishMessage();
                            NetworkServer.SendWriterToReady(base.gameObject, s_UpdateWriter, j);
                        }
                    }
                }
            }
        }
        void SendTransform()
        {
            if (!HasMoved() || ClientScene.readyConnection == null)
            {
                return;
            }

            m_LocalTransformWriter.StartMessage(MsgType.LocalChildTransform);
            m_LocalTransformWriter.Write(netId);
            m_LocalTransformWriter.WritePackedUInt32(m_ChildIndex);
            SerializeModeTransform(m_LocalTransformWriter);

            m_PrevPosition = m_Target.localPosition;
            m_PrevRotation = m_Target.localRotation;


            m_LocalTransformWriter.FinishMessage();

            ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
        }
 public override void Serialize(NetworkWriter writer) {
     writer.StartMessage(MSGID);
     //Send the number of elements
     writer.Write(inputsList.Count);//int32
     //Add the entire list
     foreach(Inputs i in inputsList) {
         writer.Write(i.crouch);//bool
         writer.Write(i.jump);//bool
         writer.Write(i.move);//bool
         writer.Write(i.pitch);//float
         writer.Write(i.rotate);//bool
         writer.Write(i.timeStamp);//long
         writer.Write(i.walk);//bool
         writer.Write(i.wasd[0]);//bool
         writer.Write(i.wasd[1]);//bool
         writer.Write(i.wasd[2]);//bool
         writer.Write(i.wasd[3]);//bool
         writer.Write(i.yaw);//float
     }
     writer.FinishMessage();
 }
Example #23
0
        protected void SendRPCInternal(NetworkWriter writer, int channelId, string rpcName)
        {
            // This cannot use NetworkServer.active, as that is not specific to this object.
            if (!isServer)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("ClientRpc call on un-spawned object");
                }
                return;
            }

            writer.FinishMessage();
            NetworkServer.SendWriterToReady(gameObject, writer, channelId);

#if UNITY_EDITOR
            UnityEditor.NetworkDetailStats.IncrementStat(
                UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
                MsgType.Rpc, rpcName, 1);
#endif
        }
 protected void SendCommandInternal(NetworkWriter writer, int channelId, string cmdName)
 {
     if (!this.isLocalPlayer && !this.hasAuthority)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("Trying to send command for object without authority.");
         }
         return;
     }
     if (ClientScene.readyConnection == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("Send command attempted with no client running [client=" + this.connectionToServer + "].");
         }
         return;
     }
     writer.FinishMessage();
     ClientScene.readyConnection.SendWriter(writer, channelId);
 }
Example #25
0
 private void SendMsg(Operation <T> op, int itemIndex, T item)
 {
     if (this.m_Behaviour == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("SyncList not initialized");
         }
     }
     else
     {
         NetworkIdentity component = this.m_Behaviour.GetComponent <NetworkIdentity>();
         if (component == null)
         {
             if (LogFilter.logError)
             {
                 Debug.LogError("SyncList no NetworkIdentity");
             }
         }
         else
         {
             NetworkWriter writer = new NetworkWriter();
             writer.StartMessage(9);
             writer.Write(component.netId);
             writer.WritePackedUInt32((uint)this.m_CmdHash);
             writer.Write((byte)op);
             writer.WritePackedUInt32((uint)itemIndex);
             this.SerializeItem(writer, item);
             writer.FinishMessage();
             NetworkServer.SendWriterToReady(component.gameObject, writer, 0);
             NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 9, op.ToString(), 1);
             if ((this.m_Behaviour.isServer && this.m_Behaviour.isClient) && (this.m_Callback != null))
             {
                 this.m_Callback(op, itemIndex);
             }
         }
     }
 }
Example #26
0
        void SendTransform()
        {
            if (!HasMoved() || ClientScene.readyConnection == null)
            {
                return;
            }

            m_LocalTransformWriter.StartMessage(MsgType.LocalChildTransform);
            m_LocalTransformWriter.Write(netId);
            m_LocalTransformWriter.WritePackedUInt32(m_ChildIndex);
            SerializeModeTransform(m_LocalTransformWriter);

            m_PrevPosition = m_Target.localPosition;
            m_PrevRotation = m_Target.localRotation;


            m_LocalTransformWriter.FinishMessage();

            //#if UNITY_EDITOR
            //            Profiler.IncrementStatOutgoing(MsgType.LocalChildTransform, "16:LocalChildTransform");
            //#endif
            ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
        }
Example #27
0
 private void SendMsg(SyncList <T> .Operation op, int itemIndex, T item)
 {
     if (this.m_Behaviour == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("SyncList not initialized");
         }
     }
     else
     {
         NetworkIdentity component = this.m_Behaviour.GetComponent <NetworkIdentity>();
         if (component == null)
         {
             if (LogFilter.logError)
             {
                 Debug.LogError("SyncList no NetworkIdentity");
             }
         }
         else if (component.isServer)
         {
             NetworkWriter networkWriter = new NetworkWriter();
             networkWriter.StartMessage(9);
             networkWriter.Write(component.netId);
             networkWriter.WritePackedUInt32((uint)this.m_CmdHash);
             networkWriter.Write((byte)op);
             networkWriter.WritePackedUInt32((uint)itemIndex);
             this.SerializeItem(networkWriter, item);
             networkWriter.FinishMessage();
             NetworkServer.SendWriterToReady(component.gameObject, networkWriter, this.m_Behaviour.GetNetworkChannel());
             if (this.m_Behaviour.isServer && this.m_Behaviour.isClient && this.m_Callback != null)
             {
                 this.m_Callback(op, itemIndex);
             }
         }
     }
 }
        void SendTransform()
        {
            if (!HasMoved() || ClientScene.readyConnection == null)
            {
                return;
            }

            m_LocalTransformWriter.StartMessage(99);// MsgType.LocalPlayerTransform);
            m_LocalTransformWriter.Write(netId);

            switch (transformSyncMode)
            {
            case TransformSyncMode.SyncNone:
            {
                return;
            }

            case TransformSyncMode.SyncTransform:
            {
                SerializeModeTransform(m_LocalTransformWriter);
                break;
            }

            case TransformSyncMode.SyncCharacterController:
            {
                SerializeModeCharacterController(m_LocalTransformWriter);
                break;
            }
            }

            m_PrevPosition = transform.localPosition;
            m_PrevRotation = transform.localRotation;

            m_LocalTransformWriter.FinishMessage();

            ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
        }
Example #29
0
        protected void SendCommandInternal(NetworkWriter writer, int channelId, string cmdName)
        {
            // local players can always send commands, regardless of authority, other objects must have authority.
            if (!(isLocalPlayer || hasAuthority))
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("Trying to send command for object without authority.");
                }
                return;
            }

            if (ClientScene.readyConnection == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Send command attempted with no client running [client=" + connectionToServer + "].");
                }
                return;
            }

            writer.FinishMessage();
            ClientScene.readyConnection.SendWriter(writer, channelId);
        }
Example #30
0
        // invoked by unity runtime immediately after the regular "Update()" function.
        internal void UNetUpdate()
        {
            // check if any behaviours are ready to send
            uint dirtyChannelBits = 0;

            for (int i = 0; i < m_NetworkBehaviours.Length; i++)
            {
                NetworkBehaviour comp = m_NetworkBehaviours[i];
                int channelId         = comp.GetDirtyChannel();
                if (channelId != -1)
                {
                    dirtyChannelBits |= (uint)(1 << channelId);
                }
            }
            if (dirtyChannelBits == 0)
            {
                return;
            }

            for (int channelId = 0; channelId < NetworkServer.numChannels; channelId++)
            {
                if ((dirtyChannelBits & (uint)(1 << channelId)) != 0)
                {
                    s_UpdateWriter.StartMessage(MsgType.UpdateVars);
                    s_UpdateWriter.Write(netId);

                    bool  wroteData = false;
                    short oldPos;
                    for (int i = 0; i < m_NetworkBehaviours.Length; i++)
                    {
                        oldPos = s_UpdateWriter.Position;
                        NetworkBehaviour comp = m_NetworkBehaviours[i];
                        if (comp.GetDirtyChannel() != channelId)
                        {
                            // component could write more than one dirty-bits, so call the serialize func
                            comp.OnSerialize(s_UpdateWriter, false);
                            continue;
                        }

                        if (comp.OnSerialize(s_UpdateWriter, false))
                        {
                            comp.ClearAllDirtyBits();

#if UNITY_EDITOR
                            UnityEditor.NetworkDetailStats.IncrementStat(
                                UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
                                MsgType.UpdateVars, comp.GetType().Name, 1);
#endif

                            wroteData = true;
                        }
                        if (s_UpdateWriter.Position - oldPos > NetworkServer.maxPacketSize)
                        {
                            if (LogFilter.logWarn)
                            {
                                Debug.LogWarning("Large state update of " + (s_UpdateWriter.Position - oldPos) + " bytes for netId:" + netId + " from script:" + comp);
                            }
                        }
                    }

                    if (!wroteData)
                    {
                        // nothing to send.. this could be a script with no OnSerialize function setting dirty bits
                        continue;
                    }

                    s_UpdateWriter.FinishMessage();
                    NetworkServer.SendWriterToReady(gameObject, s_UpdateWriter, channelId);
                }
            }
        }