Example #1
0
        internal static void Tick()
        {
            if (!IsConnected)
            {
                return;
            }
            m_Client.Tick();

            if (s_Requests.Count > 0)
            {
                var now             = Stopwatch.GetTimestamp();
                var pendingRequests = s_Requests.Values.ToArray();
                foreach (var request in pendingRequests)
                {
                    var elapsedTime = new TimeSpan(now - request.offerStartTime).TotalMilliseconds;
                    if (request.isAcknowledged)
                    {
                        continue;
                    }
                    if (elapsedTime > request.timeoutInMs)
                    {
                        CleanRequest(request.eventType);
                        Reject(request, new Exception($"Request timeout: {elapsedTime} > {request.timeoutInMs}"));
                    }
                }
            }
        }
Example #2
0
        public static void Start()
        {
            if (m_Client != null || IsConnected)
            {
                return;
            }

            m_Client = ChannelClient.GetOrCreateClient("event");
            m_Client.On(IncomingEvent);
            m_Client.Start(false);
            int tickCount = 100;

            while (!m_Client.IsConnected() && --tickCount > 0)
            {
                m_Client.Tick();
                System.Threading.Thread.Sleep(10);
            }

            EditorApplication.update += Tick;
        }