Пример #1
0
 protected override void OnDisable()
 {
     if (m_client != null)
     {
         m_client.Abort();
         m_client.Dispose();
         m_client = null;
     }
     m_payload = null;
     base.OnDisable();
 }
Пример #2
0
        void Start()
        {
            var url = sceneManager.system.staticConfig.apiInfo.list.FirstOrDefault(p => p.name == "delay").url;
            var elm = url.Split(':');

            m_client = new UDPingClient(elm[0], int.Parse(elm[1]));
            if (m_client.lastNetError != SocketError.Success)
            {
                UnityEngine.Debug.Log("DelayClient Initialize Fail.");
                m_client.Dispose();
                m_client = null;
                return;
            }
            m_payload = new byte[UDPingClient.RECV_BUFFER_SIZE];

            m_client.profile.pps            = sceneManager.system.delayProfile.pps;
            m_client.profile.pktPayloadSize = sceneManager.system.delayProfile.pktPayloadSize;
            m_client.profile.duration       = sceneManager.system.delayProfile.duration;

            m_settingTf.text = "Test: " + m_client.profile.duration.ToString() + " sec - " + m_client.profile.pktSize.ToString() + "B";

            m_barList = new List <Bar>();
            m_barNr   = MONITOR_WIDTH / 60 * m_client.profile.pps;
            float interval = (float)MONITOR_WIDTH / (float)m_barNr;
            int   idx      = 0;

            s_size.x = interval;
            s_pos.y  = 0;
            for (idx = 0; idx < m_barNr; ++idx)
            {
                var bar = new Bar();
                var go  = m_barPf.InstantiateWithOrigName();
                go.SetUIParent(m_graph);
                bar.rt  = go.GetComponent <RectTransform>();
                bar.img = go.GetComponent <Image>();

                s_pos.x = interval * idx;
                bar.rt.anchoredPosition = s_pos;
                m_barList.Add(bar);
            }
        }