/// <summary>
 /// Handles the main scriptqueue's dequeue event.  Send the data to the encoder.
 /// </summary>
 /// <param name="queue"></param>
 /// <param name="dea"></param>
 private void ScriptDequeueHandler(object queue, ScriptEventArgs sea)
 {
     if (scriptEventsEnabled)
     {
         //Debug.WriteLine("PresenterManager.ScriptDequeueHandler type=" + sea.type);
         if (OnSendRawScript != null)
         {
             OnSendRawScript(sea);
         }
     }
 }
示例#2
0
        private void enqueueMain(WorkItem wi, RTUpdate rtu)
        {
            lock (mainQueue)
                mainQueue.Add(wi);

            if (wi.Type != "URL")
            {
                if (OnEnqueue != null)
                {
                    ScriptEventArgs dea = new ScriptEventArgs(Convert.ToBase64String(wi.BC.Buffer, wi.BC.Index, wi.BC.Length), wi.Type);
                    OnEnqueue(this, dea);
                }
            }
        }
示例#3
0
        private void enqueueSub(WorkItem wi)
        {
            lock (subQueue)
                subQueue.Add(wi);

            if (wi.Type != "URL")
            {
                if (OnEnqueue != null)
                {
                    ScriptEventArgs dea = new ScriptEventArgs(Convert.ToBase64String(wi.BC.Buffer, wi.BC.Index, wi.BC.Length), wi.Type);
                    OnEnqueue(this, dea);
                    //Debug.WriteLine("ScriptQueue.enqueueSub: " + wi.ToString());
                }
            }
        }
        /// <summary>
        /// Handles the ScriptQueue OnSlideTransition event.  Send a URL script type to the encoder.
        /// </summary>
        /// <param name="url"></param>
        private void ScriptSlideTransitionHandler(Object url)
        {
            PPTLogFileWrite(url.ToString());

            if (scriptEventsEnabled)
            {
                //Debug.WriteLine("PresenterManager.ScriptSlideTransitionHandler url=" + (String)url);

                if (OnSendUrlScript != null)
                {
                    ScriptEventArgs sea = new ScriptEventArgs((String)url, "URL");
                    OnSendUrlScript(sea);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Dequeue next item from subQueue.
        /// </summary>
        /// <returns>Number of bytes dequeued</returns>
        /// Items in the subQueue which are large enough that they need to be fragmented will be
        /// skipped over.  Those items need to be promoted to the mainQueue before they will be
        /// sent.
        private int dequeueSub()
        {
            int      dequeueBytes = 0;
            int      i;
            WorkItem wi = null;
            bool     foundOne;

            lock (subQueue)
            {
                if (subQueue.Count == 0)
                {
                    return(0);
                }

                foundOne = false;
                lock (bwUpdateLockObject)                  // make sure maxBytesPerSecond doesn't change while we are in this block.
                {
                    for (i = 0; i < subQueue.Count; i++)
                    {
                        if (((WorkItem)subQueue[i]).BC.Length <= maxBytesPerSecond)
                        {
                            foundOne = true;
                            break;
                        }
                    }
                }
                if (foundOne)
                {
                    wi           = ((WorkItem)subQueue[i]);
                    dequeueBytes = wi.BC.Length;
                    subQueue.RemoveAt(i);
                }
            }
            if (foundOne)
            {
                ScriptEventArgs dea = new ScriptEventArgs(Convert.ToBase64String(wi.BC.Buffer, wi.BC.Index, wi.BC.Length), wi.Type);
                if (OnDequeue != null)
                {
                    OnDequeue(this, dea);
                }
                //Debug.WriteLine("ScriptQueue.dequeueSub: OnDequeue" + wi.ToString());
            }
            return(dequeueBytes);
        }
示例#6
0
        /// <summary>
        /// Dequeue the next item in the mainQueue.  If it needs to be fragmented, handle the fragmentation here.
        /// </summary>
        /// <returns>Number of bytes dequeued</returns>
        private int dequeueMain()
        {
            int      dequeueBytes = 0;
            WorkItem wi;
            string   stype;

            if (mainQueue.Count == 0)
            {
                return(0);
            }

            lock (mainQueue)
            {
                mainQueue.Sort(new WorkItem.WorkItemComparer());                 //sort on timestamp
                wi = ((WorkItem)mainQueue[0]);
                mainQueue.RemoveAt(0);
            }

            lock (bwUpdateLockObject)             //make sure maxBytesPerSecond doesn't change while we are in this block.
            {
                if (maxBytesPerSecond == 0)
                {
                    return(0);
                }
                if (wi.BC.Length <= maxBytesPerSecond)
                {
                    dequeueBytes = wi.BC.Length;
                    if (wi.Type == "URL")
                    {
                        String url = baseUrl + wi.DeckGuid.ToString() + "/slide" + (wi.SlideIndex + 1).ToString() + "." + extent;
                        if (OnSlideTransition != null)
                        {
                            OnSlideTransition(url);
                        }
                        lastUrl = url;
                        //Debug.WriteLine("ScriptQueue.dequeueMain: OnSlideTransition" + wi.ToString());
                    }
                    else
                    {
                        ScriptEventArgs dea = new ScriptEventArgs(Convert.ToBase64String(wi.BC.Buffer, wi.BC.Index, wi.BC.Length), wi.Type);
                        if (OnDequeue != null)
                        {
                            OnDequeue(this, dea);
                        }

                        //Debug.WriteLine("ScriptQueue.dequeueMain: OnDequeue" + wi.ToString());
                    }
                }
                else if (wi.Type != "URL")                 //if a URL needs to be fragmented, forget about it.
                {
                    // send fragments
                    while (wi.BC.Length > 0)
                    {
                        if (wi.BC.Length > maxBytesPerSecond)
                        {
                            stype        = fragmentType;
                            dequeueBytes = maxBytesPerSecond;
                        }
                        else
                        {
                            stype        = scriptType;                      // The final fragment is sent with normal script type.
                            dequeueBytes = wi.BC.Length;
                        }
                        BufferChunk     nbc = wi.BC.NextBufferChunk(dequeueBytes);
                        ScriptEventArgs dea = new ScriptEventArgs(Convert.ToBase64String(nbc.Buffer, nbc.Index, nbc.Length), stype);
                        if (OnDequeue != null)
                        {
                            OnDequeue(this, dea);
                        }
                        Debug.WriteLine("ScriptQueue.dequeueMain: OnDequeue (fragment)" + wi.ToString());
                        if (wi.BC.Length > 0)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }
            }
            return(dequeueBytes);
        }
 /// <summary>
 /// Log WebViewer compliant presentation archive
 /// </summary>
 /// <param name="queue"></param>
 /// <param name="dea"></param>
 private void ScriptEnqueueHandler(object queue, ScriptEventArgs dea)
 {
     ScriptLogFileWrite(dea.type, dea.data);
 }