public void SetStatus(ConnectionPresenceType status, string message) { ISimplePresence simplePresence = Bus.Session.GetObject <ISimplePresence> (connectionBusIFace, connectionPath); // Properties simplePresenceProperties = Bus.Session.GetObject<Properties> (connectionBusIFace, connectionPath); // IDictionary<string, object> lstStatus = (IDictionary<string, object>) simplePresenceProperties.Get("org.freedesktop.Telepathy.Connection.Interface.SimplePresence", "Statuses"); List <BaseStatus> possibleStatusLst = EmpathyStatus.GetStatusList(status); // TODO: utiliser SimplePresence au lieu de Presence IPresence presence = Bus.Session.GetObject <IPresence> (connectionBusIFace, connectionPath); IDictionary <string, StatusSpec> lstStatus = presence.GetStatuses(); foreach (BaseStatus oneStatus in possibleStatusLst) { StatusSpec statusSpec; if (lstStatus.TryGetValue(oneStatus.ToString(), out statusSpec)) { if (statusSpec.MaySetOnSelf) { simplePresence.SetPresence(oneStatus.ToString(), message); return; } } } }
private Task _client_UserPresenceUpdated(IGuildUser usr, IPresence before, IPresence after) { LogSetting logSetting; if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting) || !logSetting.LogUserPresence || before.Status == after.Status) { return(Task.CompletedTask); } ITextChannel logChannel; if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogChannelType.UserPresence)) == null) { return(Task.CompletedTask); } string str; if (before.Status != after.Status) { str = $"🔵`{prettyCurrentTime}`👤__**{usr.Username}**__ is now **{after.Status}**."; } else { str = $"👾`{prettyCurrentTime}`👤__**{usr.Username}**__ is now playing **{after.Game}**."; } UserPresenceUpdates.AddOrUpdate(logChannel, new List <string>() { str }, (id, list) => { list.Add(str); return(list); }); return(Task.CompletedTask); }
public int CompareTo(IPresence other) { int result; // If either are unavailable, we need to run comparisons on it if (other.Type.Equals(PresenceType.unavailable) || this.Type.Equals(PresenceType.unavailable)) { if (other.Type.Equals(PresenceType.unavailable) == this.Type.Equals(PresenceType.unavailable)) { return(0); } if (other.Type.Equals(PresenceType.unavailable)) { return(-1); } else { return(1); } } else { // otherwise its all about the priority result = other.Priority.CompareTo(Priority); } return(result); }
public void AddPresence(IPresence presence) { lock (_presenceLock) { if (_presences.ContainsKey(presence.Resource)) { if (presence.Type.Equals(PresenceType.unavailable)) { _presences.Remove(presence.Resource); } else { _presences[presence.Resource] = presence; } } else { _presences.Add(presence.Resource, presence); } _currentHighestPresence = null; // cache the result GetHighestPriorityPresence(); // Notify OnPropertyChanged("Mode"); OnPropertyChanged("Status"); OnPropertyChanged("Type"); OnPropertyChanged("Proirity"); OnPropertyChanged("Resource"); OnPropertyChanged("ClientInfo"); } }
public Form1() { InitializeComponent(); BootStrapper bs = new BootStrapper(); bs.Initialize(); _Presence = ServiceLocator.GetInstance<TestPresence>(); }
internal void SetPresence(IPresence presence) { _presence.AddPresence(presence); if (!Presence.IsOnline) { ActiveShortCode = null; } OnPropertyChanged("Presence"); }
private void SavePresence(IPresence presence) { var user = XSockets.Core.Utility.Storage.Repository <Guid, IPresence> .AddOrUpdate(this.PersistentId, presence); var users = XSockets.Core.Utility.Storage.Repository <Guid, IPresence> .Find(p => p.Context == this.ContextId); //this.InvokeToOthers(user, "userupdate"); this.InvokeToAll(users, "userupdate"); //this.InvokeTo(p => p.GroupId == this.GroupId, user, "userupdate"); }
public PresenceUpdatedEventArgs( Snowflake guildId, Optional <IUser> user, CachedPresence oldPresence, IPresence newPresence) { GuildId = guildId; User = user; OldPresence = oldPresence; NewPresence = newPresence; }
private IPresence GetHighestPriorityPresence() { lock (_presenceLock) { if (_currentHighestPresence == null) { Logger.Debug("Calculating highest priority presence from " + String.Join(" | ", _presences)); if (_presences.Count > 0) { var presences = new List <IPresence>(_presences.Values); // This causes an exception sometimes, we need to capture and send a fault report, so we can try figure it out try { presences.Sort(); } catch (Exception e) { try { Logger.Error( "Caught the multi presence exception we are attempting to understand, logging fault report", e); GwupeClientAppContext.CurrentAppContext.SubmitFaultReport(new FaultReport() { Subject = "Multipresence error detected", UserReport = "MultiPresence error " + String.Join(" | ", _presences.Values) }); } catch (Exception ex) { Logger.Error("Failed to generate fault report for multi presence error", ex); // throw original exception throw e; } } _currentHighestPresence = presences[0]; } } else { // Logger.Debug("Using cached highest priority presence"); } //Logger.Debug("Returning highest priority presence " + _currentHighestPresence); return(_currentHighestPresence); } return(null); }
public override ValueTask <PresenceUpdatedEventArgs> HandleDispatchAsync(IGatewayApiClient shard, PresenceJsonModel model) { if (model.GuildId == default) // just in case? { return(new(result : null)); } CachedPresence oldPresence = null; IPresence newPresence = null; if (CacheProvider.TryGetPresences(model.GuildId, out var cache)) { if (model.Status != UserStatus.Offline) { if (cache.TryGetValue(model.User.Id, out var presence)) { newPresence = presence; oldPresence = presence.Clone() as CachedPresence; newPresence.Update(model); } else { newPresence = new CachedPresence(Client, model); cache.Add(model.User.Id, newPresence as CachedPresence); } } else { cache.TryRemove(model.User.Id, out oldPresence); } } newPresence ??= new TransientPresence(Client, model); var user = Optional.Conditional(model.User.Username != null, (tuple) => { var(client, model) = tuple; return(new TransientUser(client, model) as IUser); }, (Client, model.User)); var e = new PresenceUpdatedEventArgs(model.GuildId, user, oldPresence, newPresence); return(new(e)); }
public EphemeralUser WithIPresenceData(IPresence user) { if (user is null) { return(this); } if (user.Activity != default) { Activity = user.Activity; } if (user.Status != default) { Status = user.Status; } return(this); }
public virtual void SetPresence(IPresence presence) => this.presence = presence ?? throw new System.ArgumentNullException(nameof(presence));
private void SavePresence(IPresence presence) { var user = Core.Utility.Storage.Repository<Guid, IPresence>.AddOrUpdate(this.PersistentId, presence); this.InvokeToOthers(user, "userupdate"); }
public int CompareTo(IPresence other) { int result; // If either are unavailable, we need to run comparisons on it if (other.Type.Equals(PresenceType.unavailable) || this.Type.Equals(PresenceType.unavailable)) { if (other.Type.Equals(PresenceType.unavailable) == this.Type.Equals(PresenceType.unavailable)) { return 0; } if (other.Type.Equals(PresenceType.unavailable)) { return -1; } else { return 1; } } else { // otherwise its all about the priority result = other.Priority.CompareTo(Priority); } return result; }
private void SavePresence(IPresence presence) { var user = XSockets.Core.Utility.Storage.Repository <Guid, IPresence> .AddOrUpdate(this.PersistentId, presence); this.InvokeToOthers(user, "userupdate"); }
private IPresence GetHighestPriorityPresence() { lock (_presenceLock) { if (_currentHighestPresence == null) { Logger.Debug("Calculating highest priority presence from " + String.Join(" | ", _presences)); if (_presences.Count > 0) { var presences = new List<IPresence>(_presences.Values); // This causes an exception sometimes, we need to capture and send a fault report, so we can try figure it out try { presences.Sort(); } catch (Exception e) { try { Logger.Error( "Caught the multi presence exception we are attempting to understand, logging fault report", e); GwupeClientAppContext.CurrentAppContext.SubmitFaultReport(new FaultReport() { Subject = "Multipresence error detected", UserReport = "MultiPresence error " + String.Join(" | ", _presences.Values) }); } catch (Exception ex) { Logger.Error("Failed to generate fault report for multi presence error",ex); // throw original exception throw e; } } _currentHighestPresence = presences[0]; } } else { // Logger.Debug("Using cached highest priority presence"); } //Logger.Debug("Returning highest priority presence " + _currentHighestPresence); return _currentHighestPresence; } return null; }
public int CompareTo(IPresence other) { return Priority.CompareTo(other.Priority); }
public string HubConnect() { _Bs = new BootStrapper(); _Bs.Initialize(); _Presence = ServiceLocator.GetInstance<SignalRPresence>(); _Hub = new HubConnection(ChannelURL); _proxy = _Hub.CreateHubProxy(HubName); _proxy.On<ERPRequest>("incomingRequest", request => DoERPRequest(request)); _Hub.Start().Wait(); _proxy.Invoke("registerRequestHandler", _Hub.ConnectionId, _Hub.ConnectionId); return _Hub.ConnectionId; }
private Task _client_UserPresenceUpdated(IGuildUser usr, IPresence before, IPresence after) { LogSetting logSetting; if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting) || !logSetting.LogUserPresence || before.Status == after.Status) return Task.CompletedTask; ITextChannel logChannel; if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogChannelType.UserPresence)) == null) return Task.CompletedTask; string str; if (before.Status != after.Status) str = $"🔵`{prettyCurrentTime}`👤__**{usr.Username}**__ is now **{after.Status}**."; else str = $"👾`{prettyCurrentTime}`👤__**{usr.Username}**__ is now playing **{after.Game}**."; UserPresenceUpdates.AddOrUpdate(logChannel, new List<string>() { str }, (id, list) => { list.Add(str); return list; }); return Task.CompletedTask; }
public int CompareTo(IPresence other) { return(Priority.CompareTo(other.Priority)); }
public static bool UserActive(this IPresence user) => user != null && (user.Status == UserStatus.Online || user.Status == UserStatus.DoNotDisturb);