Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
<ProjectReference Include="..\Cyaim.WebSocketServer\Cyaim.WebSocketServer.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Dtos\" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>E:\WorkSpaces\WebSocketServer\Cyaim.WebSocketServer\Cyaim.WebSocketServer\Cyaim.WebSocketServer.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand All @@ -42,10 +38,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />-->
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cyaim.WebSocketServer.Infrastructure.Attributes
{
/// <summary>
/// WebSocket Endpoint mark
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Method)]
public class WebSocketAttribute : Attribute
{
/// <summary>
/// Mark action use action name
/// </summary>
public WebSocketAttribute()
{
}
public WebSocketAttribute() { }

/// <summary>
/// Mark action use method value
Expand All @@ -31,4 +27,4 @@ public WebSocketAttribute(string method) : this()
/// </summary>
public string Method { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Cyaim.WebSocketServer.Infrastructure.Configures;
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Text;

namespace Cyaim.WebSocketServer.Infrastructure.Cluster
{
Expand All @@ -17,8 +15,8 @@ public static class GlobalClusterCenter
public static ClusterOption ClusterContext { get; set; }

/// <summary>
/// All nodes
/// All nodes
/// </summary>
public static List<WebSocket> Nodes { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cyaim.WebSocketServer.Infrastructure.Configures
namespace Cyaim.WebSocketServer.Infrastructure.Configures
{
/// <summary>
/// Cluster configure
Expand Down Expand Up @@ -30,10 +26,8 @@ public class ClusterOption
/// Only NodeLevel are valid for Master.
/// </summary>
public bool IsEnableLoadBalance { get; set; }

}


/// <summary>
/// Service node
/// </summary>
Expand All @@ -43,9 +37,10 @@ public enum ServiceLevel
/// Master node
/// </summary>
Master,

/// <summary>
/// Slave node
/// </summary>
Slave,
Slave
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Reflection;

namespace Cyaim.WebSocketServer.Infrastructure.Configures
{
Expand All @@ -20,4 +17,4 @@ public struct ConstructorParameter
/// </summary>
public ParameterInfo[] ParameterInfos { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using System.Reflection;
using System.Text;

namespace Cyaim.WebSocketServer.Infrastructure.Configures
{
Expand All @@ -18,7 +16,7 @@ public class WatchAssemblyContext
public string WatchAssemblyPath { get; set; }

/// <summary>
/// Type in assemblys
/// Type in assemblies
/// </summary>
public List<Type> WatchAssemblyTypes { get; set; }

Expand All @@ -41,18 +39,18 @@ public class WatchAssemblyContext
/// Constructor parameter list
/// K class type,V class constructor parameter list
/// </summary>
public Dictionary<Type, ConstructorParameter[]> CoustructorParameters { get; set; }
public Dictionary<Type, ConstructorParameter[]> ConstructorParameters { get; set; }

/// <summary>
/// Constructor most parameter in class
/// K Class type,V Constructor parameter
/// </summary>
public Dictionary<Type, ConstructorParameter> MaxCoustructorParameters { get; set; }
public Dictionary<Type, ConstructorParameter> MaxConstructorParameters { get; set; }

/// <summary>
/// Method parameter list in class public method
/// K MethodInfo,V ParameterInfo
/// </summary>
public Dictionary<MethodInfo, ParameterInfo[]> MethodParameters { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Cyaim.WebSocketServer.Infrastructure.Configures
{
Expand Down Expand Up @@ -39,6 +37,5 @@ public class WebSocketEndPoint
/// Endpoint where class
/// </summary>
public Type Class { get; set; }

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

// ReSharper disable ClassWithVirtualMembersNeverInherited.Global

namespace Cyaim.WebSocketServer.Infrastructure.Configures
{
/// <summary>
Expand Down Expand Up @@ -85,7 +84,6 @@ public class WebSocketRouteOption
/// <param name="logger">logger</param>
/// <param name="webSocketOptions">WebSocket configure option</param>
/// <returns></returns>

public delegate Task WebSocketChannelHandler(HttpContext context, ILogger<WebSocketRouteMiddleware> logger, WebSocketRouteOption webSocketOptions);

/// <summary>
Expand Down Expand Up @@ -120,61 +118,62 @@ public virtual Task<bool> OnBeforeConnection(HttpContext context, WebSocketRoute
return Task.FromResult(true);
}


/// <summary>
/// Close connectioned handler
/// Close Connected handler
/// </summary>
/// <param name="context"></param>
/// <param name="webSocketOptions"></param>
/// <param name="channel"></param>
/// <param name="logger"></param>
/// <returns></returns>
public delegate Task DisConnectionedHandler(HttpContext context, WebSocketRouteOption webSocketOptions, string channel, ILogger<WebSocketRouteMiddleware> logger);
public delegate Task DisConnectedHandler(HttpContext context, WebSocketRouteOption webSocketOptions, string channel, ILogger<WebSocketRouteMiddleware> logger);

/// <summary>
/// Close connectioned call
/// Close Connected call
/// </summary>
public event DisConnectionedHandler DisConnectionedEvent;
public event DisConnectedHandler DisConnectedEvent;

/// <summary>
/// DisConnectionedEvent entry
/// DisConnectedEvent entry
/// </summary>
/// <param name="context"></param>
/// <param name="webSocketOptions"></param>
/// <param name="channel"></param>
/// <param name="logger"></param>
/// <returns></returns>
public virtual Task OnDisConnectioned(HttpContext context, WebSocketRouteOption webSocketOptions, string channel, ILogger<WebSocketRouteMiddleware> logger)
public virtual Task OnDisConnected(HttpContext context, WebSocketRouteOption webSocketOptions, string channel, ILogger<WebSocketRouteMiddleware> logger)
{
if (DisConnectionedEvent != null)
if (DisConnectedEvent != null)
{
return DisConnectionedEvent(context, webSocketOptions, channel, logger);
return DisConnectedEvent(context, webSocketOptions, channel, logger);
}
return Task.CompletedTask;
}
#endregion

#endregion

#region System.Text.Json Options

/// <summary>
/// JsonSerialiazerOptions
/// JsonSerializerOptions
/// </summary>
public JsonSerializerOptions DefaultRequestJsonSerialiazerOptions { get; set; } = new JsonSerializerOptions
public JsonSerializerOptions DefaultRequestJsonSerializerOptions { get; set; } = new JsonSerializerOptions
{
// 设置为 true 以忽略属性名称的大小写
PropertyNameCaseInsensitive = true,
WriteIndented = false,
WriteIndented = false
};

/// <summary>
/// JsonSerialiazerOptions
/// JsonSerializerOptions
/// </summary>
public JsonSerializerOptions DefaultResponseJsonSerialiazerOptions { get; set; } = new JsonSerializerOptions
public JsonSerializerOptions DefaultResponseJsonSerializerOptions { get; set; } = new JsonSerializerOptions
{
// 设置为 true 以忽略属性名称的大小写
PropertyNameCaseInsensitive = true,
WriteIndented = false,
WriteIndented = false
};

#endregion
}
}
}
Loading