public void SendMessage(AgregatorUser user, string message) { if (user.ActiveDialog != null && user.DialogExpire < DateTime.Now) { SendMessage(user.ActiveDialog, message); } else { //Create sending engeine; foreach (ChatterUser item in user.Chatters) { item.ClculateHistoricalRates(); } var list = user.Chatters.OrderBy(x => x.ResponseTime.TotalSeconds * x.ActivityRate); var Tasks = list.Select(x => new Task(() => { if (user.ActiveDialog == null) { SendMessage(x, message); Task.Delay(x.ResponseTime).Wait(); } })).ToArray(); for (int i = 1; i < Tasks.Length; i++) { Tasks[(i - 1) / 2].ContinueWith(((x, n) => Tasks[(int)n].Start()), i); } Tasks[0].Start(); } }
public IEnumerable <Message> GetChatMessages(AgregatorUser user, Action <ChatterUser> LoadStoredMessages) { foreach (ChatterUser item in user.Chatters) { LoadStoredMessages(item); } return(GetChatMessages(user)); }
public void AddUser(ChatterUser source, string id) { var destination = new AgregatorUser(id); Users.Add(destination); AddUser(source, destination); }
public IEnumerable <Message> GetChatMessages(AgregatorUser user) { var Messages = new List <Message>().AsEnumerable(); foreach (ChatterUser item in user.Chatters) { Messages = Messages.Concat(GetChatMessages(item)); } Messages.OrderBy(x => x.Time); return(Messages); }
public ChatterUser(ChatterUserData data, Core core) { this.Name = data.Name.Split(']')[1]; this.UserId = data.UserId; this.Chatter = core.Chatters.First(x => x.Id == data.ChatterId); if (data.AgregatorUserId != null) { this.AgregatorUser = core.Users.First(x => x.Name == data.AgregatorUserId); this.AgregatorUser.Chatters.Add(this); } }
public bool ChangeUserKey(AgregatorUser user, string name) { if (string.IsNullOrWhiteSpace(name) || (Users.Any(x => x.Name == name))) { return(false); } else { user.Name = name; } return(true); }
public void AddUser(ChatterUser source, AgregatorUser destination) { //ChatterUsers.Remove(source); destination.Chatters.Add(source); source.AgregatorUser = destination; }