Beispiel #1
0
        /// <summary>
        ///  Updates over the network arrive here - AFTER the Update() runs (not tested for all platforms... thanks unet for the great docs.)
        ///  The incoming bitstream is read
        /// </summary>
        /// <param name="msg"></param>
        private static void ReceiveUpdate(NetworkMessage msg)
        {
            UdpBitStream bitstream = new UdpBitStream(msg.reader.ReadBytesNonAlloc(NSTMaster.bitstreamByteArray, msg.reader.Length), msg.reader.Length);
            UdpBitStream outstream = new UdpBitStream(NSTMaster.outstreamByteArray);

            NSTMaster.ReceiveUpdate(ref bitstream, ref outstream, NetworkServer.active);

            BandwidthUsage.ReportMasterBits(ref bitstream, BandwidthLogType.MasterIn);

            // Write a clone message and pass it to all the clients if this is the server receiving
            if (NetworkServer.active)             // && msg.conn == nst.NI.clientAuthorityOwner)
            {
                writer.StartMessage(msg.msgType);
                //writer.WriteUncountedByteArray(bitstream.Data, msg.reader.Length);
                writer.WriteUncountedByteArray(outstream.Data, outstream.BytesUsed);
                writer.SendPayloadArrayToAllClients(msg.msgType);
            }
        }