Beispiel #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aSessionId">
 /// The unique identifier of the session that the tab is in.
 /// </param>
 /// <param name="aTabKey">
 /// An identifier for this tab, unique within its session.
 /// </param>
 /// <param name="aListener">
 /// A listener that will be notified about changes to the state of the
 /// event queue. Used to implement the "server health" app.
 /// Important: The event-handler will be invoked while some app-state
 /// locks are held. To avoid deadlock, it's a good idea to use
 /// TabStatusQueue to transfer the events to another thread.
 /// </param>
 /// <param name="aClock">
 /// Provides access to the current UTC time. Production code should
 /// likely use ()=>DateTime.UtcNow, testing code will want more direct
 /// control over the perceived time.
 /// </param>
 /// <param name="aTimeoutPolicy">
 /// Policy on how long to keep long polls alive and how long to
 /// keep a tab alive with no outstanding long poll.
 /// </param>
 /// <param name="aTimerThread">
 /// Timer for scheduling maintenance work, such as checking for
 /// expired tabs and long polls.
 /// </param>
 /// <param name="aAppsStateThread">
 /// The soft thread for scheduling all asynchronous work. When we
 /// get invoked from the timer thread, we dispatch back to this
 /// thread before touching any of our mutable state.
 /// </param>
 /// <param name="aSession">
 /// Something that wants to know when a tab should expire due to
 /// inactivity.
 /// </param>
 /// <param name="aAppRecord">
 /// AppRecord associated with the tab.
 /// </param>
 public ServerTab(
     string aSessionId,
     string aTabKey,
     ITabStatusListener aListener,
     Func<DateTime> aClock,
     ServerTabTimeoutPolicy aTimeoutPolicy,
     ITimerThread aTimerThread,
     IStrand aAppsStateThread,
     ISession aSession,
     AppRecord aAppRecord)
 {
     SessionId = aSessionId;
     iListener = aListener;
     iAppsStateThread = aAppsStateThread;
     iSession = aSession;
     iTimerThread = aTimerThread;
     iClock = aClock;
     iTimeoutPolicy = aTimeoutPolicy;
     TabKey = aTabKey;
     AppRecord = aAppRecord;
     iEventQueue = new JsonEventQueue(12000);// aEventQueue;
     iLastRead = iClock();
     iTimerCallback = iTimerThread.RegisterCallback(
         ()=>iAppsStateThread.ScheduleExclusive(DoMaintenance));
     RescheduleMaintenance();
 }
Beispiel #2
0
 public AppsStateFactory(ITabStatusListener aTabListener, Func<DateTime> aClock, ServerTabTimeoutPolicy aTimeoutPolicy, UserList aUserList)
 {
     iAppsStateThread = new Strand();
     iTabStatusQueue = new TabStatusQueue(aTabListener);
     iTimeoutPolicy = aTimeoutPolicy;
     iUserList = aUserList;
     iClock = aClock;
     iTimerThread = new TimerThread(iClock);
 }