-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Renamed ProtocolServer.ConnectionFilter to ProtocolServer.Filter - Removed unused extension file - Cleaned up connection filters - Moved to 0.4.1
- Loading branch information
1 parent
a25a281
commit ac1d9c2
Showing
13 changed files
with
170 additions
and
83 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ProtoSocket.Filters | ||
{ | ||
/// <summary> | ||
/// Provides an asyncronous connection filter implementation | ||
/// </summary> | ||
public class AsyncConnectionFilter : IConnectionFilter | ||
{ | ||
private Func<IncomingContext, CancellationToken, Task<bool>> _delegate; | ||
|
||
bool IConnectionFilter.IsAsynchronous { | ||
get { | ||
return true; | ||
} | ||
} | ||
|
||
bool IConnectionFilter.Filter(IncomingContext incomingCtx) { | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
Task<bool> IConnectionFilter.FilterAsync(IncomingContext incomingCtx, CancellationToken cancellationToken) { | ||
return _delegate(incomingCtx, cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new connection filter with the specific delegate. | ||
/// </summary> | ||
/// <param name="func">The function to filter connections.</param> | ||
public AsyncConnectionFilter(Func<IncomingContext, CancellationToken, Task<bool>> func) { | ||
_delegate = func; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ProtoSocket.Filters | ||
{ | ||
/// <summary> | ||
/// Provides an synchronous connection filter implementation | ||
/// </summary> | ||
public class ConnectionFilter : IConnectionFilter | ||
{ | ||
private Func<IncomingContext, bool> _delegate; | ||
|
||
bool IConnectionFilter.IsAsynchronous { | ||
get { | ||
return false; | ||
} | ||
} | ||
|
||
bool IConnectionFilter.Filter(IncomingContext incomingCtx) { | ||
return _delegate(incomingCtx); | ||
} | ||
|
||
Task<bool> IConnectionFilter.FilterAsync(IncomingContext incomingCtx, CancellationToken cancellationToken) { | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new connection filter with the specific delegate. | ||
/// </summary> | ||
/// <param name="func">The function to filter connections.</param> | ||
public ConnectionFilter(Func<IncomingContext, bool> func) { | ||
_delegate = func; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Text; | ||
|
||
namespace ProtoSocket | ||
{ | ||
/// <summary> | ||
/// Represents an incoming connection context. | ||
/// </summary> | ||
public struct IncomingContext | ||
{ | ||
/// <summary> | ||
/// Gets the network endpoint. | ||
/// </summary> | ||
public EndPoint RemoteEndPoint { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the server. | ||
/// </summary> | ||
public IProtocolServer Server { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the string representation | ||
/// </summary> | ||
/// <returns></returns> | ||
public override string ToString() { | ||
return RemoteEndPoint.ToString(); | ||
} | ||
} | ||
} |
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