예제 #1
0
        /// <summary>
        /// Start a new session
        /// </summary>
        public SessionId Start(SessionId sessionId, int timeoutSeconds, Map <string, object> initialState)
        {
            lock (sync)
            {
                if (sessions.ContainsKey(sessionId))
                {
                    return(sessionId);
                }
                var session = SessionVector.Create(timeoutSeconds, VectorConflictStrategy.First, initialState);
                sessions = sessions.Add(sessionId, session);

                // Create a subject per session that will buffer touches so we don't push too
                // much over the net when not needed.  This routes to a single stream that isn't
                // buffered.
                var touch = new Subject <Tuple <SessionId, DateTime> >();
                touch.Sample(TimeSpan.FromSeconds(1))
                .ObserveOn(TaskPoolScheduler.Default)
                .Subscribe(touched.OnNext);
                sessionTouched = sessionTouched.Add(sessionId, touch);
            }
            return(sessionId);
        }
 public ActorRequestContext(
     ActorSystem system,
     ActorItem self,
     ProcessId sender,
     ActorItem parent,
     object currentMsg,
     ActorRequest currentRequest,
     ProcessFlags processFlags,
     ProcessOpTransaction ops,
     SessionVector session
     )
 {
     Self = self;
     Sender = sender;
     Parent = parent;
     CurrentMsg = currentMsg;
     CurrentRequest = currentRequest;
     ProcessFlags = processFlags;
     Ops = ops;
     System = system;
     Session = session;
 }