-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added npackage handking cancellation token
- Loading branch information
1 parent
7f5d67a
commit ca9439b
Showing
28 changed files
with
122 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
src/SuperSocket.Server.Abstractions/DelegatePackageHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using SuperSocket.Server.Abstractions.Session; | ||
|
||
namespace SuperSocket.Server.Abstractions | ||
{ | ||
public class DelegatePackageHandler<TReceivePackageInfo> : IPackageHandler<TReceivePackageInfo> | ||
{ | ||
|
||
Func<IAppSession, TReceivePackageInfo, ValueTask> _func; | ||
Func<IAppSession, TReceivePackageInfo, CancellationToken, ValueTask> _func; | ||
|
||
public DelegatePackageHandler(Func<IAppSession, TReceivePackageInfo, ValueTask> func) | ||
{ | ||
_func = (session, package, cancellationToken) => func(session, package); | ||
} | ||
|
||
public DelegatePackageHandler(Func<IAppSession, TReceivePackageInfo, CancellationToken, ValueTask> func) | ||
{ | ||
_func = func; | ||
} | ||
|
||
public async ValueTask Handle(IAppSession session, TReceivePackageInfo package) | ||
public async ValueTask Handle(IAppSession session, TReceivePackageInfo package, CancellationToken cancellationToken) | ||
{ | ||
await _func(session, package); | ||
await _func(session, package, cancellationToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using SuperSocket.Server.Abstractions.Session; | ||
|
||
namespace SuperSocket.Server.Abstractions | ||
{ | ||
public interface IPackageHandler<TReceivePackageInfo> | ||
{ | ||
ValueTask Handle(IAppSession session, TReceivePackageInfo package); | ||
ValueTask Handle(IAppSession session, TReceivePackageInfo package, CancellationToken cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using SuperSocket.Server.Abstractions.Session; | ||
|
||
namespace SuperSocket.Server | ||
{ | ||
public class SerialPackageHandlingScheduler<TPackageInfo> : PackageHandlingSchedulerBase<TPackageInfo> | ||
{ | ||
public override async ValueTask HandlePackage(IAppSession session, TPackageInfo package) | ||
public override async ValueTask HandlePackage(IAppSession session, TPackageInfo package, CancellationToken cancellationToken) | ||
{ | ||
await HandlePackageInternal(session, package); | ||
await HandlePackageInternal(session, package, cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.