Example #1
0
        protected void OnProfilerRequest(ref MyControlProfilerMsg data, ulong sender)
        {
            if (IsServer && !m_profilerSenders.ContainsKey(sender))
            {
                MemoryStream profilerStream = new MemoryStream();

                MyObjectBuilder_Profiler profilerData = MyObjectBuilder_Profiler.GetObjectBuilder(VRage.Profiler.MyRenderProfiler.GetProfilerAtIndex(data.index));
                MyObjectBuilderSerializer.SerializeXML(profilerStream, profilerData, MyObjectBuilderSerializer.XmlCompression.Gzip);
                SyncLayer.TransportLayer.SendFlush(sender);
                var buffer = profilerStream.ToArray();
                MyMultipartSender msgSender = new MyMultipartSender(buffer, buffer.Length, sender, MyMultiplayer.ProfilerDownloadChannel);
                m_profilerSenders[sender] = msgSender;
            }
        }
Example #2
0
        void MyDownloadProfilerResult_Received(byte[] data, int dataSize, ulong sender, MyTimeSpan timestamp, MyTimeSpan receivedTime)
        {
            if (m_finished)
            {
                m_mp.SendAck(sender, m_channel, m_receiveMsg.BlockCount - 1, m_receiveMsg.BlockCount);
                return;
            }

            if (m_sender == sender)
            {
                var status = m_receiveMsg.Compose(data, dataSize, sender);
                switch (status)
                {
                case MyMultipartMessage.Status.InProgress:
                    break;

                case MyMultipartMessage.Status.Finished:
                    MyNetworkReader.ClearHandler(m_channel);

                    m_receiveMsg.Stream.Position = 0;
                    if (m_receiveMsg.Stream.Length > 0)
                    {
                        MyObjectBuilder_Profiler profilerBuilder;
                        MyObjectBuilderSerializer.DeserializeGZippedXML(m_receiveMsg.Stream, out profilerBuilder);
                        VRage.Profiler.MyRenderProfiler.SelectedProfiler     = MyObjectBuilder_Profiler.Init(profilerBuilder);
                        VRage.Profiler.MyRenderProfiler.IsProfilerFromServer = true;
                    }
                    m_finished = true;
                    break;

                case MyMultipartMessage.Status.Error:
                    MyNetworkReader.ClearHandler(m_channel);
                    break;
                }
            }
        }