using System.Threading; using xPushService.Base; using xAiModels.Constants; using xCommons.Extensions; using xAiModels.Models.Dtos; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; namespace xAiModels.Providers.Hubs { public class XAiDataProviderHub : XBaseHub { public XAiDataProviderHub( ILogger logger ) : base(logger) { } // #region XAiProject ... /// /// Notify a New Item Created ... /// /// /// /// public async Task ProjectCreated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ProjectCreated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Removed ... /// /// /// /// public async Task ProjectRemoved( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ProjectRemoved.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Updated ... /// /// /// /// public async Task ProjectUpdated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ProjectUpdated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } #endregion // #region XAiConversation ... /// /// Notify a New Item Created ... /// /// /// /// public async Task ConversationCreated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ConversationCreated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Removed ... /// /// /// /// public async Task ConversationRemoved( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ConversationRemoved.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Updated ... /// /// /// /// public async Task ConversationUpdated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.ConversationUpdated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } #endregion // #region XAiMessage ... /// /// Notify a New Item Created ... /// /// /// /// public async Task MessageCreated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.MessageCreated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Removed ... /// /// /// /// public async Task MessageRemoved( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.MessageRemoved.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } /// /// Notify an Item Updated ... /// /// /// /// public async Task MessageUpdated( XAiProjectDto item, CancellationToken cancellationToken = default ) { // var connectionId = Context.ConnectionId; if (!connectionId.IsNullOrEmpty()) { // await Clients .AllExcept(connectionId) .SendAsync( XAiDataProviderHubActions.MessageUpdated.GetStringValue(), item.ToJSON(camelCase: true), connectionId, cancellationToken ); } } #endregion } }