https://github.com/awatercolorpen/holeoverhttp
Library to help providing server api and connection to client
https://github.com/awatercolorpen/holeoverhttp
connection-pool dotnet-core http network-security-groups websocket
Last synced: 12 days ago
JSON representation
Library to help providing server api and connection to client
- Host: GitHub
- URL: https://github.com/awatercolorpen/holeoverhttp
- Owner: AWaterColorPen
- License: mit
- Created: 2018-01-14T07:41:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T05:22:30.000Z (over 3 years ago)
- Last Synced: 2025-03-16T11:20:30.422Z (about 1 year ago)
- Topics: connection-pool, dotnet-core, http, network-security-groups, websocket
- Language: C#
- Homepage: https://www.nuget.org/packages/HoleOverHttp/
- Size: 79.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HoleOverHttp
[](https://dev.azure.com/hellis/GitHub/_build/latest?definitionId=4&branchName=master)
[](https://badge.fury.io/nu/HoleOverHttp)
Library to help providing server api and connection to client.
Implementation in C#, targeting .NET Standard 2.1+.
The library can help server acoss network security groups and firewall to provider api and connection to multi clients.
## Usage
- Install
```shell
Install-Package HoleOverHttp
```
- Provider Connection
```cs
IAuthorizationProvider authorizationProvider = new Mock().Object;
var providerConnection = new WebSocketProviderConnection(host: "localhost:23333", namespace: "namespace", tokenProvider: authorizationProvider);
// set secure
providerConnection.Secure = false;
```
- Service Object as a class
```cs
public class ServiceObject
{
public int MethodName(int param)
{
return param * param;
}
}
```
- Server Provider
```cs
// register service and connection
var serverProvider = new ReflectCallProvider();
serverProvider.RegisterConnection(providerConnection);
serverProvider.RegisterService(new ServiceObject());
// run serve async
var tokenSource = new CancellationTokenSource();
await serverProvider.ServeAsync(tokenSource.Token);
```
- Client Call Registry
```cs
// create a call registry instance
var callConnectionPool = new ReusableCallConnectionPool();
// have to implementation your own CallRegistry instance
var webListenerCallRegistry = new WebListenerCallRegistry(callConnectionPool: callConnectionPool, prefixes: new[] { "http://localhost:23333/ws/" }));
// enable remote register
var tokenSource = new CancellationTokenSource();
webListenerCallRegistry.RegisterRemoteSocket(tokenSource.Token);
```
- Client Call
```cs
var result = callConnectionPool.CallAsync(namespace: "namespace", method: "MethodName", param: Encoding.UTF8.GetBytes("{param:0}")).Result;
```