Coder Social home page Coder Social logo

asp-net-signalr-poc's Introduction

AspNET SignalR POC

Proof of concept of a .NET Framework server that sends messages to clients through SignalR.
The goal of this project was to understand the feasibility/blockers/unknowns around the following topics:

  • Hosting a bare bones Http Server on a .NET Framework library project
  • Expose a WebAPI with public endpoints
  • Send real-time data as WebSocket messages with SignalR
    • Available serialization formats (preference for binary)

The outcome would help me on deciding if this setup would be a good fit for a Unity game project and for my requirements.

Running the project

  1. Clone the repository
  2. Startup both projects (server first, client after)
    ℹ️ Tip: if you are using Rider, it should automatically load a multi launch configuration in .run folder that runs the projects in the correct order with one click
  3. Make a GET request to the server curl http://localhost:9000/api/values

image

Results

Area Comments
Self hosted Http Server
Expose public endpoints
SignalR dependencies - Server and Client must use specific SignalR packages (SignalR package differences)
- If the Server is .NET Framework, it must use Microsoft.AspNet.SignalR
- .NET Core clients that wish to connect to the server must use Microsoft.AspNet.SignalR.Client (instead of Microsoft.AspNetCore.SignalR.Client)
Server dependency footprint Large. Multiple .dlls must be imported into Unity to support a self hosted API and SignalR.
SignalR serialization ASP.NET SignalR implementation for .NET Framework supports Json out of the box but doesn't provide support for binary formats such as protobuf or MessagePack

Outcome

Self hosting a WebAPI and sending WebSocket messages with SignalR required little to no effort.
ASP.NET SignalR limits the serialization format choices that can be used. It might be possible to overcome this limitation at the cost of more effort/custom logic, but without any guarantees that it will work.
Integration with Unity will result in several Microsoft.* .dlls that need to be imported - more susceptible to version conflicts and errors.

I decided to abandon this approach and use a WebSocket library that allows me to serialize messages with protobuf while also exposing public endpoints.
All in the same package and fewer .dlls

asp-net-signalr-poc's People

Contributors

sparcopt 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.