Example #1
0
        public SupervisorActor(Inbox inbox, ActorExceptionHandler handler,
                               Action<ActorRef, ActorRestartLimitReached> restartLimitReachedHandler)
        {
            _inbox = inbox;
            inbox.SetExceptionHandler(handler);

            inbox.Receive<ActorRestartLimitReached>(msg => restartLimitReachedHandler(inbox, msg));
        }
Example #2
0
        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; });
        }
Example #3
0
		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());
				});
			});
		}
Example #4
0
File: Deck.cs Project: Nangal/Stact
		public Deck(Inbox inbox)
		{
			inbox.Receive<Request<DrawCard>>(x =>
				{
					if (_cards.Count > 0)
					{
						Card card = _cards.Dequeue();
						x.Respond(new DrawnCard(card));
					}
				});
		}
Example #5
0
        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;
                });
        }
Example #6
0
 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();
                 });
         });
 }
Example #7
0
            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();
                                        });
                                });
                        }
                    });
            }
Example #8
0
        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);
                });
        }
Example #9
0
		public Player(Inbox inbox)
		{
			_normalBet = new Bet(25.0m);

			inbox.Loop(hand =>
				{
					hand.Receive<Request<Bet>>(x =>
						{
							x.Respond(_normalBet);

							inbox.Loop(loop =>
								{
								});
						});
				});
		}
Example #10
0
 public InboxSlackPerUserAdapter(string guid, Inbox inbox, InboxAdapterAppCredential appCredential, InboxOptions?adapterOptions = null) : base(guid, inbox, appCredential, adapterOptions)
 {
 }
Example #11
0
    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;
        }
    }
Example #12
0
 /// <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));
 }
Example #13
0
 public void Store(Letter m)
 => Inbox.Add(m);
Example #14
0
		static AnonymousActor CreateAnonymousActor(Fiber fiber, Scheduler scheduler, Inbox inbox)
		{
			return new AnonymousActor(fiber, scheduler, inbox);
		}
Example #15
0
    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);
    }
Example #16
0
            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();
                                });
                    });
            }
Example #17
0
		public Dealer(Inbox inbox)
		{
			
		}
Example #18
0
 public void Toss(string id)
 => Inbox.Remove(GetLetter(id));
Example #19
0
 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)
 {
 }
Example #21
0
		public TraceActor(Inbox inbox)
		{
		}
Example #22
0
		public Auction(Inbox inbox)
		{
		}
Example #23
0
 public void Setup() {
     _sut = new Inbox<int>();
 }
Example #24
0
			public ServiceController(Inbox inbox)
			{
				Paused = new Future<bool>();
				Started = new Future<bool>();
				Stopped = new Future<bool>();
			}
Example #25
0
 public void TossMarkedAt(int i)
 => Inbox.RemoveAt(Inbox.IndexOf(Marked.ElementAt(i)));
Example #26
0
 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");
 }
Example #27
0
 public Letter GetLetterAt(int i)
 => Inbox.ElementAt(i);
Example #28
0
 public InboxSpec()
 {
     _inbox = Inbox.Create(sys);
 }
Example #29
0
 /// <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);
 }
Example #30
0
 public void TossAt(int i)
 => Inbox.RemoveAt(i);
Example #31
0
        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");
        }
Example #32
0
 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;
 }
Example #34
0
 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);
 }
Example #36
0
		AnonymousActor(Fiber fiber, Scheduler scheduler, Inbox inbox)
		{
			_fiber = fiber;
			_scheduler = scheduler;
			_inbox = inbox;
		}
Example #37
0
 public BusinessObjectActionReport <DataRepositoryActionStatus> Update(Inbox inbox)
 {
     return(_CMSSectionManager.Update(inbox.CMSSection));
 }
Example #38
0
 /// <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));
 }
Example #39
0
		/// <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);
		}
Example #40
0
        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;
        }
Example #41
0
			public QuoteService(Inbox inbox)
			{
			}
Example #42
0
        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];
        }
Example #43
0
 public bool AddMessageToInbox(Message c)
 {
     Inbox.Add(c);
     return(true);
 }
Example #44
0
 public BusinessObjectActionReport <DataRepositoryActionStatus> Delete(Inbox inbox)
 {
     return(_CMSSectionManager.Delete(inbox.CMSSection, false));
 }
Example #45
0
 public bool RemoveMessageFromInbox(Message c)
 {
     Inbox.Remove(c);
     return(true);
 }
Example #46
0
 /// <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);
            }
        }
Example #48
0
 /// <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));
 }
Example #49
0
 private void InitializedObjects()
 {
     SearchWith = new Inbox(TextElement);
     KeyBoard   = new ActionControl();
 }
Example #50
0
 public Auction(Inbox inbox)
 {
 }
Example #51
0
        //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);
Example #52
0
 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);
 }
Example #53
0
 public void ClearThreads()
 => Inbox.RemoveAll(x => x.IsThreaded);
Example #54
0
            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);
            }
Example #55
0
 // takes all Letters that are not marked as spam.
 public void ClearMarked()
 => Inbox = Inbox.TakeWhile(x => !x.Marked).ToList();
Example #56
0
 public void Toss(Letter l)
 => Inbox.Remove(l);
Example #57
0
 public LoginService(IActorRef activeUsersActor, Inbox inbox)
     : base(activeUsersActor, inbox)
 {
 }