Exemplo n.º 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();
 }
Exemplo n.º 2
0
 public AppSessionRecord(AppRecord aAppRecord)
 {
     AppRecord = aAppRecord;
 }
Exemplo n.º 3
0
 public ServerTab CreateServerTab(string aSessionId, string aTabId, SessionRecord aSessionRecord, AppRecord aAppRecord)
 {
     return new ServerTab(aSessionId, aTabId, iTabStatusQueue, iClock, iTimeoutPolicy, iTimerThread, iAppsStateThread, aSessionRecord, aAppRecord);
 }
Exemplo n.º 4
0
        //public
        public ServerTab CreateTab(AppRecord aApp, string aUserId)
        {
            SwitchUser(aUserId);
            ServerTab newServerTab;

            iCounter += 1;
            string tabKey = iCounter.ToString();
            iListener.NewTab(Key, tabKey, iUserId, aApp.Id);
            BrowserTabProxy browserTabProxy = new BrowserTabProxy();
            browserTabProxy.ServerTab = newServerTab = Tabs[tabKey] = iAppsStateFactory.CreateServerTab(Key, tabKey, this, aApp);
            User user;
            if (iUserId==null || !iUserList.TryGetUserById(iUserId, out user))
            {
                user = null;
            }
            var serverTab = aApp.App.CreateTab(browserTabProxy, user);
            newServerTab.AppTab = new AppThreadScheduler(serverTab, aApp.Strand);
            return newServerTab;
        }
Exemplo n.º 5
0
 public AppRecord AddApp(string aName, IRawXapp aApp)
 {
     return Apps[aName] = new AppRecord(aApp, aName, new Strand());
 }