GithubHelp home page GithubHelp logo

awatercolorpen / holeoverhttp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 81 KB

Library to help providing server api and connection to client

Home Page: https://www.nuget.org/packages/HoleOverHttp/

License: MIT License

C# 100.00%
dotnet-core websocket http connection-pool network-security-groups

holeoverhttp's Introduction

HoleOverHttp

Build Status NuGet version

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
Install-Package HoleOverHttp
  • Provider Connection
IAuthorizationProvider authorizationProvider = new Mock<IAuthorizationProvider>().Object;
var providerConnection = new WebSocketProviderConnection(host: "localhost:23333", namespace: "namespace", tokenProvider: authorizationProvider);

// set secure
providerConnection.Secure = false;
  • Service Object as a class
public class ServiceObject
{
    public int MethodName(int param)
    {
        return param * param;
    }
}
  • Server Provider
// 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
// 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
var result = callConnectionPool.CallAsync(namespace: "namespace", method: "MethodName", param: Encoding.UTF8.GetBytes("{param:0}")).Result;

holeoverhttp's People

Contributors

awatercolorpen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.