![]() |
VOOZH | about |
dotnet add package IczpNet.Pusher.Application.Contracts --version 9.0.1.903
NuGet\Install-Package IczpNet.Pusher.Application.Contracts -Version 9.0.1.903
<PackageReference Include="IczpNet.Pusher.Application.Contracts" Version="9.0.1.903" />
<PackageVersion Include="IczpNet.Pusher.Application.Contracts" Version="9.0.1.903" />Directory.Packages.props
<PackageReference Include="IczpNet.Pusher.Application.Contracts" />Project file
paket add IczpNet.Pusher.Application.Contracts --version 9.0.1.903
#r "nuget: IczpNet.Pusher.Application.Contracts, 9.0.1.903"
#:package IczpNet.Pusher.Application.Contracts@9.0.1.903
#addin nuget:?package=IczpNet.Pusher.Application.Contracts&version=9.0.1.903Install as a Cake Addin
#tool nuget:?package=IczpNet.Pusher.Application.Contracts&version=9.0.1.903Install as a Cake Tool
abpvnext push module
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);
}
}
PusherHttpApiHostModule.cs
[DependsOn(typeof(IczpNetPusherXXXXXXModule))][DependsOn(typeof(IczpNetPusherModule))]
public class IMServerModule : AbpModule
{
//...
}
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 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
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.HttpApi
Pusher for abpVNext |
|
|
IczpNet.Pusher.Application
Pusher for abpVNext |
This package is not used by any popular GitHub repositories.
add logo