コード例 #1
0
ファイル: NSTMaster.cs プロジェクト: vert0r/NetDemo2
        /// <summary>
        /// Ping all owned NSTs for any due updates. Passes the bitstream to that NST to write to.
        /// </summary>
        public static void PollAllForUpdates()
        {
            //Debug.Log("<b><color=green>Mstr Ping</color></b> " + (Time.time - tempMasterPollTime));
            //tempMasterPollTime = Time.time;

            UdpBitStream bitstream = new UdpBitStream(bitstreamByteArray);
            UdpBitStream outstream = new UdpBitStream();

            bool foundUpdate = false;

            for (int i = 0; i < NetworkSyncTransform.allNsts.Count; i++)
            {
                foundUpdate |= NetworkSyncTransform.allNsts[i].PollForUpdate(ref bitstream);
            }

            // No Updates, we are done.
            if (!foundUpdate)
            {
                return;
            }

            // Write the end of stream marker of 00
            bitstream.WriteBool(false);

            mna.SendUpdate(ref bitstream, ref outstream);

            //Debug.Log("<b><color=blue>Mstr Snd</color></b> " + (Time.time - tempMasterSendTime));
            //tempMasterSendTime = Time.time;
        }
コード例 #2
0
ファイル: NSTMaster.cs プロジェクト: lenix2/VRProject
        // Create the master bitstream and poll for updates
        private static void PollForUpdates(int updateCounter, bool isOfftick)
        {
            UdpBitStream bitstream = new UdpBitStream(NSTMaster.bitstreamByteArray);
            UdpBitStream outstream = new UdpBitStream();

            bitstream.WriteInt(updateCounter, 6);

            bool updatesFound = PollAllForNSTUpdates(ref bitstream, isOfftick ? NSTTools.allNstsWithOfftick : NSTTools.allNsts, updateCounter, isOfftick);

            if (!isOfftick)
            {
                MasterRTT.Send(ref bitstream, updateCounter);
            }

            /// Additional Data after NST Updates added to stream here

            // Send every tick, or if anything offtick was found
            if (updatesFound || !isOfftick)
            {
                MasterNetAdapter.SendUpdate(ref bitstream, ref outstream);
            }
        }