IczpNet.Pusher.Application.Contracts
9.0.1.903
.NET 9.0
This package targets .NET 9.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package IczpNet.Pusher.Application.Contracts --version 9.0.1.903
NuGet\Install-Package IczpNet.Pusher.Application.Contracts -Version 9.0.1.903
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IczpNet.Pusher.Application.Contracts" Version="9.0.1.903" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IczpNet.Pusher.Application.Contracts --version 9.0.1.903
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IczpNet.Pusher.Application.Contracts, 9.0.1.903"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IczpNet.Pusher.Application.Contracts as a Cake Addin #addin nuget:?package=IczpNet.Pusher.Application.Contracts&version=9.0.1.903 // Install IczpNet.Pusher.Application.Contracts as a Cake Tool #tool nuget:?package=IczpNet.Pusher.Application.Contracts&version=9.0.1.903
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Iczp.Pusher
abpvnext push module
IczpNet.Pusher.Domain.Shared
CommandAttribute.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace IczpNet.Pusher.Commands;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class CommandAttribute : Attribute
{
public string Command { get; }
public CommandAttribute(string command)
{
Command = command;
}
public static string GetValue<T>()
{
return GetValue(typeof(T));
}
public static List<string> GetValues<T>()
{
return GetValues(typeof(T));
}
public static List<string> GetValues(Type type)
{
var nameAttributes = type.GetCustomAttributes<CommandAttribute>();
if (!nameAttributes.Any())
{
return [type.FullName];
}
return nameAttributes.Select(x => x.Command).ToList();
}
public static string GetValue(Type type)
{
var nameAttribute = type.GetCustomAttribute<CommandAttribute>();
if (nameAttribute == null)
{
return type.FullName;
}
return nameAttribute.Command;
}
}
TicketInfo.cs
using System;
namespace IczpNet.Pusher.Tickets;
public class TicketInfo
{
public string Id { get; set; }
public string ConnectionId { get; set; }
public Guid AppUserId { get; set; }
public string DeviceId { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long ExpireSeconds { get; set; }
public override string ToString()
{
return $"Id={Id},ConnectionId={ConnectionId},AppUserId={AppUserId},DeviceId={DeviceId},CreationTime={CreationTime},ExpireSeconds={ExpireSeconds}";
}
}
DeviceIdAuditLogContributor.cs
加入审计日志
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Users;
namespace IczpNet.Pusher.DeviceIds;
public class DeviceIdAuditLogContributor : AuditLogContributor//, ITransientDependency
{
//protected IDeviceIdResolver DeviceIdResolver { get; }
//protected IOptions<PusherOptions> Options { get; }
//public DeviceIdAuditLogContributor(IDeviceIdResolver deviceIdResolver,
// IOptions<PusherOptions> options)
//{
// DeviceIdResolver = deviceIdResolver;
// Options = options;
//}
public override void PreContribute(AuditLogContributionContext context)
{
//deviceId for user
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
if (currentUser != null)
{
var userDeviceId = currentUser.FindClaimValue(DeviceIdExtensions.DeviceIdClaim);
context.AuditInfo.SetProperty(DeviceIdExtensions.DeviceIdClaim, userDeviceId);
}
var htpContextAccessor = context.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
htpContextAccessor.HttpContext.Request.Headers
.Where(x => x.Key != "User-Agent")
.Where(x => x.Key != "Authorization")
.Where(x => !string.IsNullOrEmpty(x.Value))
.ToList()
.ForEach(x =>
{
context.AuditInfo.SetProperty(x.Key, x.Value);
});
////deviceId for request header
//var deviceIdResolver = context.ServiceProvider.GetRequiredService<IDeviceIdResolver>();
//void setProperty(string key)
//{
// var value = deviceIdResolver.GetHeader(key);
// if (!string.IsNullOrEmpty(value))
// {
// context.AuditInfo.SetProperty(key, value);
// }
//}
//new List<string>() { "app-platform", "app-id", "app-version", deviceIdResolver.GetDeviceIdKey() }.ForEach(setProperty);
}
public override void PostContribute(AuditLogContributionContext context)
{
//context.AuditInfo.Comments.Add("Some comment deviceId...");
}
}
DeviceIdClaimsPrincipalContributor.cs
加入用户 Claims
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Claims;
namespace IczpNet.Pusher.DeviceIds;
public class DeviceIdClaimsPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency
{
//public const string DeviceIdClaim = "device_id";
protected IDeviceIdResolver DeviceIdResolver { get; }
public DeviceIdClaimsPrincipalContributor(IDeviceIdResolver deviceIdResolver)
{
DeviceIdResolver = deviceIdResolver;
}
public async Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
{
var identity = context.ClaimsPrincipal.Identities.FirstOrDefault();
//var userId = identity?.FindUserId();
//if (!userId.HasValue)
//{
// return;
//}
var deviceId = await DeviceIdResolver.GetDeviceIdAsync();
if (!string.IsNullOrWhiteSpace(deviceId))
{
identity.AddIfNotContains(new Claim(DeviceIdExtensions.DeviceIdClaim, deviceId, ClaimValueTypes.Integer));
}
}
}
DeviceIdExtensions.cs
using Volo.Abp.Users;
namespace IczpNet.Pusher.DeviceIds;
public static class DeviceIdExtensions
{
public const string DeviceIdClaim = "device_id";
/// <summary>
/// Get DeviceId by ICurrentUser
/// </summary>
/// <param name="currentUser"></param>
/// <returns></returns>
public static string GetDeviceId(this ICurrentUser currentUser)
{
return currentUser.FindClaimValue(DeviceIdClaim);
}
}
Usage
IczpNet.Pusher.HttpApi.Host
PusherHttpApiHostModule.cs
[DependsOn(typeof(IczpNetPusherXXXXXXModule))]
[DependsOn(typeof(IczpNetPusherModule))]
public class IMServerModule : AbpModule
{
//...
}
ConfigureServices
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
//...
Configure<PusherOptions>(options =>
{
options.Redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
});
//...
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
//...
app.UsePusherSubscriber(); //add this line
}
appsettings.json
{
"Redis": {
"Configuration": "127.0.0.1"
},
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- IczpNet.Pusher.Domain.Shared (>= 9.0.1.903)
- Volo.Abp.Authorization (>= 9.0.3)
- Volo.Abp.Ddd.Application.Contracts (>= 9.0.3)
-
.NETStandard 2.1
- IczpNet.Pusher.Domain.Shared (>= 9.0.1.903)
- Volo.Abp.Authorization (>= 9.0.3)
- Volo.Abp.Ddd.Application.Contracts (>= 9.0.3)
-
net9.0
- IczpNet.Pusher.Domain.Shared (>= 9.0.1.903)
- Volo.Abp.Authorization (>= 9.0.3)
- Volo.Abp.Ddd.Application.Contracts (>= 9.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on IczpNet.Pusher.Application.Contracts:
Package | Downloads |
---|---|
IczpNet.Chat.Application.Contracts
Chat module for abp |
|
IczpNet.Pusher.HttpApi.Client
Pusher for abpVNext |
|
IczpNet.Pusher.Application
Pusher for abpVNext |
|
IczpNet.Pusher.HttpApi
Pusher for abpVNext |
GitHub repositories
This package is not used by any popular GitHub repositories.
add logo