Exemplo n.º 1
0
        public 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)
                    {
                        var eventType = request.eventType;
                        CleanRequest(request.eventType);
                        Reject(request, new TimeoutException($"Request timeout for {eventType} ({elapsedTime} > {request.timeoutInMs})"));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void Start()
        {
            if (m_Client != null || isConnected)
            {
                return;
            }

            m_Client = ChannelClient.GetOrCreateClient("event");
            m_Client.RegisterMessageHandler(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;
        }