public SupervisorActor(Inbox inbox, ActorExceptionHandler handler, Action<ActorRef, ActorRestartLimitReached> restartLimitReachedHandler) { _inbox = inbox; inbox.SetExceptionHandler(handler); inbox.Receive<ActorRestartLimitReached>(msg => restartLimitReachedHandler(inbox, msg)); }
public Auction(Fiber fiber, Inbox inbox, Guid id) { Id = id; _inbox = inbox; _fiber = fiber; AskChannel = new SelectiveConsumerChannel<Request<Ask>>(_fiber, HandleAsk); EndChannel = new ConsumerChannel<End>(_fiber, x => { _ended = true; }); }
public Auction(Inbox inbox, Fiber fiber, Scheduler scheduler) { _currentBid = 1.00m; scheduler.Schedule(60000, fiber, () => { inbox.Send(new EndAuction()); }); inbox.Loop(loop => { loop.Receive<Request<AuctionStatus>>(request => { request.Respond(new AuctionStatusImpl { CurrentBid = _currentBid, IsOpen = _open, }); }); loop.Receive<Request<PlaceBid>>(request => { if (request.Body.MaximumBid <= _currentBid) { request.Respond(new OutBidImpl { CurrentBid = _currentBid }); } else { _currentBid = request.Body.MaximumBid; request.Respond(new BidAcceptedImpl { CurrentBid = _currentBid }); if (_highBidder != null) { _highBidder.Send(new OutBidImpl { CurrentBid = _currentBid }); } _highBidder = request.ResponseChannel; } loop.Continue(); }); loop.Receive<EndAuction>(msg => { _open = false; // _highBidder.Send(new YouWin()); }); }); }
public Deck(Inbox inbox) { inbox.Receive<Request<DrawCard>>(x => { if (_cards.Count > 0) { Card card = _cards.Dequeue(); x.Respond(new DrawnCard(card)); } }); }
public PeerHandler(Fiber fiber, Scheduler scheduler, Inbox inbox, SubscriptionObserver observer) { _observer = observer; _endpointSubscriptionCache = new EndpointSubscriptionCache(fiber, scheduler, observer); inbox.Receive<InitializePeerHandler>(init => { _peerId = init.PeerId; _peerUri = init.PeerUri; }); }
public static ReceiveLoop EnableSuspendResume(this ReceiveLoop loop, Inbox inbox) { return loop.Receive<Suspend>(pause => { // we are going to only receive a continue until we get it inbox.Receive<Resume>(x => { // repeat the loop now loop.Continue(); }); }); }
public RingNode(Inbox inbox) { inbox.Receive<Request<Init>>(init => { if (init.Body.NodeCount == 0) { init.Respond(new Token { RemainingRounds = init.Body.RoundCount }); inbox.Loop(loop => { loop.Receive<Token>(token => { int remaining = token.RemainingRounds - 1; if (remaining == 0) _complete.Complete(true); else { init.Respond(new Token { RemainingRounds = remaining, }); loop.Continue(); } }); }); } else { ActorRef next = _ringNodeFactory.GetActor(); next.Request(new Init { NodeCount = init.Body.NodeCount - 1, RoundCount = init.Body.RoundCount, }, init.ResponseChannel); inbox.Loop(loop => { loop.Receive<Token>(token => { next.Send(token); loop.Continue(); }); }); } }); }
public PeerHandler(Inbox inbox, SubscriptionObserver observer, SubscriptionRepository repository) { _observer = observer; inbox.Receive<InitializePeerHandler>(init => { _peerId = init.PeerId; _peerUri = init.PeerUri; _endpointSubscriptionCache = new EndpointSubscriptionCache(observer, _peerUri, repository); }); }
public Player(Inbox inbox) { _normalBet = new Bet(25.0m); inbox.Loop(hand => { hand.Receive<Request<Bet>>(x => { x.Respond(_normalBet); inbox.Loop(loop => { }); }); }); }
public InboxSlackPerUserAdapter(string guid, Inbox inbox, InboxAdapterAppCredential appCredential, InboxOptions?adapterOptions = null) : base(guid, inbox, appCredential, adapterOptions) { }
public bool presist(InboxDTO entity) { try { model.Inbox obj = new Inbox(); obj.userName = entity.userName; obj.messageId = entity.messageId; obj.date = entity.date; obj.unread = entity.unread; obj.message = entity.message; ctx.Inboxes.InsertOnSubmit(obj); ctx.SubmitChanges(); return true; } catch (Exception) { ctx.Dispose(); ctx = new ModelDataContext(); return false; } }
/// <summary> /// Calls the specified method when a message of the requested type is received. The /// consumer is asked if the message should be parsed, and returns a non-null action /// if the message should be passed to the consumer. At that point, the message is removed /// from the mailbox and delivered to the consumer /// </summary> /// <typeparam name = "T">The requested message type</typeparam> /// <param name="inbox">The inbox to receive the message from</param> /// <param name = "consumer">The consumer</param> /// <param name = "timeout">The time period to wait for a message</param> /// <param name = "timeoutCallback">The method to call if a message is not received within the timeout period</param> public static PendingReceive Receive <T>(this Inbox inbox, Consumer <T> consumer, TimeSpan timeout, Action timeoutCallback) { return(inbox.Receive <T>(x => consumer, timeout, timeoutCallback)); }
public void Store(Letter m) => Inbox.Add(m);
static AnonymousActor CreateAnonymousActor(Fiber fiber, Scheduler scheduler, Inbox inbox) { return new AnonymousActor(fiber, scheduler, inbox); }
public void addResponse(Response r) { GameObject response = Instantiate(responseTemplate); response.GetComponent <ResponseOption>().response.text = r.text; int type = offerType(response, r); if (type == 5) { //TODO: parse path sender and cue epilogue response.GetComponent <Button> ().onClick.AddListener(() => { player.removeMessage(r.messageIndex); Inbox inbox = GameObject.FindGameObjectWithTag("Inbox").GetComponent <Inbox>(); string characterPath = getStringFromResponse(r.path, 0); if (characterPath.Equals("ignore")) { } else { string storyPath = getStringFromResponse(r.path, 2); /* * inbox.populateEpilogue(characterPath, storyPath, character.name); * inbox.epilogue.npc.characterAssignment = character.characterAssignment; * inbox.epilogue.cue (); */ //TODO: Track Epilogue //BELIEF ID = Unhealthy, Healthy, // GetComponent<PlayerBehavior>().trackEvent(6, inbox.epilogue.endingType.ToString(),r.belief, characterPath); } }); } else if (type == 1) { response.GetComponent <Button> ().onClick.AddListener(() => { player.removeMessage(r.messageIndex); string p = getStringFromResponse(r.path, 1); // GetComponent<PlayerBehavior>().trackEvent(2, "IGNORE","none", p); Debug.Log("Removing offer with path: " + p); int offerCount = PlayerPrefs.GetInt(p + "_offers", 0); PlayerPrefs.SetInt(p + "_offers", offerCount - 1); // player.previewInbox.messageContainer.SetActive(true); Destroy(gameObject); // player.refreshInbox(); // player.previewInbox.checkIfEmpty(); }); } else if (type != -1) { response.GetComponent <Button> ().onClick.AddListener(() => { //TODO: Track Event Accepting Offer player.removeMessage(r.messageIndex); string p = getStringFromResponse(r.path, 0); // GetComponent<PlayerBehavior>().trackEvent(2, "ACCEPT", "none", p); Debug.Log("Removing offer with path: " + p); int offerCount = PlayerPrefs.GetInt(p + "_offers", 0); PlayerPrefs.SetInt(p + "_offers", offerCount - 1); // player.previewInbox.checkIfEmpty(); // player.takeAction(true); //TODO: Check for piercing, hair offer types if (type == 6) { //piercing // player.previewInbox.messageContainer.SetActive(true); Destroy(gameObject); // player.refreshInbox(); // player.previewInbox.checkIfEmpty(); transform.parent.gameObject.SetActive(false); } else if (type == 7) { //haircut // player.previewInbox.messageContainer.SetActive(true); Destroy(gameObject); // player.refreshInbox(); // player.previewInbox.checkIfEmpty(); transform.parent.gameObject.SetActive(false); } else { player.loadSceneNumber(type); } }); } else { response.GetComponent <Button> ().onClick.AddListener(() => { respond(r.path, r.messageIndex, r.belief); // player.previewInbox.checkIfEmpty(); }); } response.transform.SetParent(responseContainer, false); }
public Agent(Inbox inbox) { inbox.Loop(loop => { loop .EnableSuspendResume(inbox) .Receive<Add>(add => { _values.Add(add.Value); loop.Repeat(); }) .Receive<Request<Status>>(request => { request.Respond(new Status { Count = _values.Count, InOrder = !_values.Where((t, i) => t != i).Any(), }); loop.Repeat(); }); }); }
public Dealer(Inbox inbox) { }
public void Toss(string id) => Inbox.Remove(GetLetter(id));
public InboxSpec() : base("akka.actor.inbox.inbox-size=1000") //Default is 1000 but just to make sure these tests don't fail we set it { _inbox = Inbox.Create(Sys); }
public RegisterService(IActorRef activeUsersActor, Inbox inbox) : base(activeUsersActor, inbox) { }
public TraceActor(Inbox inbox) { }
public Auction(Inbox inbox) { }
public void Setup() { _sut = new Inbox<int>(); }
public ServiceController(Inbox inbox) { Paused = new Future<bool>(); Started = new Future<bool>(); Stopped = new Future<bool>(); }
public void TossMarkedAt(int i) => Inbox.RemoveAt(Inbox.IndexOf(Marked.ElementAt(i)));
protected void gv_Unread_SelectedIndexChanged(object sender, EventArgs e) { Session["Thread"] = gv_Unread.SelectedRow.Cells[0].Text; Inbox.ExpertRead(gv_Unread.SelectedRow.Cells[0].Text); Response.Redirect("~/ExpertPages/ExpertMessages.aspx"); }
public Letter GetLetterAt(int i) => Inbox.ElementAt(i);
public InboxSpec() { _inbox = Inbox.Create(sys); }
/// <summary> /// Sends an Exit message to an actor instance /// </summary> /// <param name = "instance">The actor instance</param> /// <param name = "sender">The exit request sender</param> public static SentRequest<Exit> Exit(this ActorRef instance, Inbox sender) { return instance.Request<Exit>(sender); }
public void TossAt(int i) => Inbox.RemoveAt(i);
public ActionResult CheckOut() { BuyNet.User u =(BuyNet.User)Session["User"]; List < Order >oU= client.GetOrders().Where(o => o.User.Id == u.Id).ToList(); foreach (var item in oU) { if(item.DateOfPayment==null) { item.DateOfPayment = DateTime.Now; client.Edit_Order(item.Id, item); Inbox inbox = new Inbox(); inbox.Sender = 11; inbox.Receiver = u.Id; inbox.Date = DateTime.Now; inbox.Topic = "Your Order have been approve"; inbox.Content = u.UserName + ", your order details have been succesfuly approve got your order details/n" + "Order number: " + item.Id + " " + item.DateOfPayment + " /n "; int sum = 0; foreach (var orp in item.OrderProduct) { inbox.Content+= orp.Product + " " + orp.Product.Price + " " + orp.Quantity +" /n"; sum += int.Parse(orp.Product.Price.ToString()) * orp.Quantity; } inbox.Content += "/n Total :" +sum +"/n card number 345 have been aprove./n Thank u for buying in BuyNet"; client.AddInbox(inbox); break; } } return RedirectToAction("UserP"); }
public Letter GetLetter(string id) => Inbox.Where(x => x.Id == id).First();
public IdleLandsBehaviour(IActorRef system, Inbox inbox) { _activeUsersActor = system; _inbox = inbox; this.EmitOnPing = true; }
public IEnumerable <Letter> FromAuthor(ulong id) => Inbox.Where(x => x.Author.Id == id);
public AgentStateManager(List <IActorRef> collectorRefs, Inbox inbox) { _collectorRefs = collectorRefs; _inbox = inbox; _logger = LogManager.GetLogger(TargetNames.LOG_AKKA); }
AnonymousActor(Fiber fiber, Scheduler scheduler, Inbox inbox) { _fiber = fiber; _scheduler = scheduler; _inbox = inbox; }
public BusinessObjectActionReport <DataRepositoryActionStatus> Update(Inbox inbox) { return(_CMSSectionManager.Update(inbox.CMSSection)); }
/// <summary> /// Sends an Exit message to an actor instance /// </summary> /// <param name = "instance">The actor instance</param> /// <param name = "sender">The exit request sender</param> public static SentRequest <Exit> Exit(this ActorRef instance, Inbox sender) { return(instance.Request <Exit>(sender)); }
/// <summary> /// Initiates a link to another actor instance. Once linked, if either actor /// exits, all actors linked to this actor will be sent an Exit with a reason /// of actor death /// </summary> /// <param name="actor">The actor to link</param> /// <param name="inbox">The inbox of the actor requesting the link</param> public static SentRequest<Link> Link(this ActorRef actor, Inbox inbox) { return actor.Request<Link>(inbox); }
private async void LoadMore(bool force = false) { LoadingVisibility = true; if (force) { if (DisplaySentMessages) { Outbox = new List <MalMessageModel>(); } else { _loadedPages = 1; Inbox = new List <MalMessageModel>(); } } if (!DisplaySentMessages) { try { if (!_skipLoading) { _loadedSomething = true; try { Inbox.AddRange(await AccountMessagesManager.GetMessagesAsync(_loadedPages++)); } catch (WebException) { ResourceLocator.MalHttpContextProvider.ErrorMessage("Messages"); } } _skipLoading = false; MessageIndex.Clear(); MessageIndex.AddRange(Inbox); LoadMorePagesVisibility = true; } catch (ArgumentOutOfRangeException) { LoadMorePagesVisibility = false; } } else { try { if (Outbox.Count == 0) { Outbox = await AccountMessagesManager.GetSentMessagesAsync(); } MessageIndex.Clear(); MessageIndex.AddRange(Outbox); LoadMorePagesVisibility = false; } catch (Exception) { ResourceLocator.MalHttpContextProvider.ErrorMessage("Messages"); } } LoadingVisibility = false; }
public QuoteService(Inbox inbox) { }
private void GetInbox() { Inbox inbox = new Inbox(); this.dataGridView1.DataSource = inbox.GetInbox(this.textBox1.Text, this.dateTimePicker1.Value, this.dateTimePicker2.Value, this.textBox2.Text, ClubID).Tables[0]; }
public bool AddMessageToInbox(Message c) { Inbox.Add(c); return(true); }
public BusinessObjectActionReport <DataRepositoryActionStatus> Delete(Inbox inbox) { return(_CMSSectionManager.Delete(inbox.CMSSection, false)); }
public bool RemoveMessageFromInbox(Message c) { Inbox.Remove(c); return(true); }
/// <summary> /// Calls the specified method when a message of the requested type is received. The /// consumer is asked if the message should be parsed, and returns a non-null action /// if the message should be passed to the consumer. At that point, the message is removed /// from the mailbox and delivered to the consumer /// </summary> /// <typeparam name = "T">The requested message type</typeparam> /// <param name="inbox">The inbox to receive the message from</param> /// <param name = "consumer">The consumer</param> public static PendingReceive Receive <T>(this Inbox inbox, Consumer <T> consumer) { return(inbox.Receive <T>(x => consumer)); }
public override void NativeCallback(string message) { const string VARIABLES_CHANGED = "VariablesChanged:"; const string VARIABLES_CHANGED_NO_DOWNLOAD_PENDING = "VariablesChangedAndNoDownloadsPending:"; const string STARTED = "Started:"; const string VARIABLE_VALUE_CHANGED = "VariableValueChanged:"; const string FORCE_CONTENT_UPDATE_WITH_HANDLER = "ForceContentUpdateWithHandler:"; const string DEFINE_ACTION_RESPONDER = "ActionResponder:"; const string ON_ACTION_RESPONDER = "OnAction:"; const string RUN_ACTION_NAMED_RESPONDER = "OnRunActionNamed:"; if (message.StartsWith(VARIABLES_CHANGED)) { VariablesChanged?.Invoke(); } else if (message.StartsWith(VARIABLES_CHANGED_NO_DOWNLOAD_PENDING)) { VariablesChangedAndNoDownloadsPending?.Invoke(); } else if (message.StartsWith(STARTED)) { if (started != null) { startSuccessful = message.EndsWith("1"); started(startSuccessful); } } else if (message.StartsWith(VARIABLE_VALUE_CHANGED)) { // Drop the beginning of the message to get the name of the variable // Then dispatch to the correct variable VariableValueChanged(message.Substring(21)); } else if (message.StartsWith(FORCE_CONTENT_UPDATE_WITH_HANDLER)) { string[] values = message.Substring(FORCE_CONTENT_UPDATE_WITH_HANDLER.Length).Split(':'); int key = Convert.ToInt32(values[0]); bool success = values[1] == "1"; if (ForceContentUpdateHandlersDictionary.TryGetValue(key, out Leanplum.ForceContentUpdateHandler handler)) { handler(success); ForceContentUpdateHandlersDictionary.Remove(key); } } else if (message.StartsWith(DEFINE_ACTION_RESPONDER)) { string key = message.Substring(DEFINE_ACTION_RESPONDER.Length); string actionName = GetActionNameFromMessageKey(key); ActionContext.ActionResponder callback; if (ActionRespondersDictionary.TryGetValue(actionName, out callback)) { string messageId = GetMessageIdFromMessageKey(key); var context = new ActionContextApple(key, messageId); ActionContextsDictionary[key] = context; callback(context); } } else if (message.StartsWith(ON_ACTION_RESPONDER)) { string key = message.Substring(ON_ACTION_RESPONDER.Length); string actionName = GetActionNameFromMessageKey(key); if (OnActionRespondersDictionary.TryGetValue(actionName, out List <ActionContext.ActionResponder> callbacks)) { if (!ActionContextsDictionary.ContainsKey(key)) { string messageId = GetMessageIdFromMessageKey(key); var newContext = new ActionContextApple(key, messageId); ActionContextsDictionary[key] = newContext; } ActionContext context = ActionContextsDictionary[key]; foreach (var callback in callbacks) { callback(context); } } } else if (message.StartsWith(RUN_ACTION_NAMED_RESPONDER)) { char keysSeparator = '|'; string data = message.Substring(RUN_ACTION_NAMED_RESPONDER.Length); string[] keys = data.Split(new char[] { keysSeparator }, StringSplitOptions.RemoveEmptyEntries); if (keys.Length != 2) { return; } string parentKey = keys[0]; string actionKey = keys[1]; if (ActionContextsDictionary.TryGetValue(parentKey, out ActionContext parentContext)) { var context = new ActionContextApple(actionKey, GetMessageIdFromMessageKey(actionKey)); parentContext.TriggerActionNamedResponder(context); } } if (Inbox != null) { Inbox.NativeCallback(message); } }
/// <summary> /// Calls the specified method when a message of the requested type is received. The /// consumer is asked if the message should be parsed, and returns a non-null action /// if the message should be passed to the consumer. At that point, the message is removed /// from the mailbox and delivered to the consumer /// </summary> /// <typeparam name = "T">The requested message type</typeparam> /// <param name="inbox">The inbox to receive the message from</param> /// <param name = "consumer">The consumer</param> /// <param name = "timeout">The time period to wait for a message</param> /// <param name = "timeoutCallback">The method to call if a message is not received within the timeout period</param> public static PendingReceive Receive <T>(this Inbox inbox, SelectiveConsumer <T> consumer, int timeout, Action timeoutCallback) { return(inbox.Receive(consumer, timeout.Milliseconds(), timeoutCallback)); }
private void InitializedObjects() { SearchWith = new Inbox(TextElement); KeyBoard = new ActionControl(); }
//clearcut methods - will try to execute, without checking... /// <summary> /// Remove all <see cref="Letter"/> sources that aren't locked from the inbox. /// </summary> public void ClearInbox() => Inbox.RemoveAll(x => !x.Locked);
public void ClearThreads() => Inbox.RemoveAll(x => x.IsThreaded);
public override Structs.TaskQueue GetMessages(Apollo.Agent agent) { Structs.TaskQueue result; List <Task> finalTaskList = new List <Task>(); List <Structs.DelegateMessage> finalDelegateList = new List <Structs.DelegateMessage>(); Structs.CheckTaskingRequest req = new Structs.CheckTaskingRequest() { action = "get_tasking", tasking_size = 1 }; if (DelegateMessageRequestQueue.Count > 0) { DelegateMessageRequestMutex.WaitOne(); req.delegates = DelegateMessageRequestQueue.ToArray(); DelegateMessageRequestQueue.Clear(); //DelegateMessageQueue = new List<Dictionary<string, string>>(); DelegateMessageRequestMutex.ReleaseMutex(); } // Could add delegate post messages string json = JsonConvert.SerializeObject(req); string taskingId = Guid.NewGuid().ToString(); if (Send(taskingId, json)) { string response = (string)Inbox.GetMessage(taskingId); Mythic.Structs.CheckTaskingResponse resp = JsonConvert.DeserializeObject <Mythic.Structs.CheckTaskingResponse>(response); foreach (Task task in resp.tasks) { Debug.WriteLine("[-] CheckTasking - NEW TASK with ID: " + task.id); finalTaskList.Add(task); } if (resp.delegates != null) { foreach (Dictionary <string, string> delegateMessage in resp.delegates) { foreach (KeyValuePair <string, string> item in delegateMessage) { finalDelegateList.Add(new Structs.DelegateMessage() { UUID = item.Key, Message = item.Value }); } } } } result = new Structs.TaskQueue() { Tasks = finalTaskList.ToArray(), Delegates = finalDelegateList.ToArray() }; //result.Add("tasks", finalTaskList.ToArray()); //result.Add("delegates", finalDelegateList.ToArray()); //SCTask task = JsonConvert.DeserializeObject<SCTask>(Post(json)); return(result); }
// takes all Letters that are not marked as spam. public void ClearMarked() => Inbox = Inbox.TakeWhile(x => !x.Marked).ToList();
public void Toss(Letter l) => Inbox.Remove(l);
public LoginService(IActorRef activeUsersActor, Inbox inbox) : base(activeUsersActor, inbox) { }