コード例 #1
0
        // ------------------------------------------------------------------------
        // This coroutine spawns a thread to send the statement to the LRS
        // ------------------------------------------------------------------------
        private IEnumerator SendStatementCoroutine(RemoteLRSAsync endPoint, List <QueuedStatement> queuedStatements)
        {
            int idState = -1;

            do
            {
                if (idState != -1)                 // means the previous request fail, we wait fiew seconds to retry
                {
                    yield return(new WaitForSeconds(10));
                }
                idState = SendStatementsImmediate(endPoint, queuedStatements);
                // Wait answer
                while (!endPoint.states[idState].complete)
                {
                    yield return(null);
                }
            } while (!endPoint.states[idState].success);


            // Client callback with result
            foreach (QueuedStatement qs in queuedStatements)
            {
                qs.callback?.Invoke(endPoint.endpoint, endPoint.states[idState].success, endPoint.states[idState].response);
            }
        }
コード例 #2
0
        public void Init(GBLConfig config, int queueDepth = 1000)
        {
            _lrsEndpoint    = new RemoteLRSAsync(GBLConfig.LrsURL, config.lrsUser, config.lrsPassword);
            _statementQueue = new RingBuffer <QueuedStatement>(queueDepth);

            ReadyToSend = true;
        }
コード例 #3
0
        //return idState of posted statements
        private int SendStatementsImmediate(RemoteLRSAsync endPoint, List <QueuedStatement> queuedStatements)
        {
            List <Statement> statements = new List <Statement>();

            foreach (QueuedStatement qs in queuedStatements)
            {
                statements.Add(qs.statement);
            }
            return(endPoint.PostStatements(statements));
        }