Giter Club home page Giter Club logo

hazel-networking's Introduction

Hazel Networking is a low-level networking library for C# providing connection-oriented, message based communication via UDP and RUDP.

The aim of this fork is to create a simple interface for ultra-fast connection-based UDP communication for games.


Features

  • UDP and Reliable UDP.
  • UDP Broadcast for local-multiplayer.
  • Completely thread safe.
  • All protocols are connection oriented (similar to TCP) and message based (similar to UDP)
  • IPv4 and IPv6 support
  • Automatic statistics about data passing in and out of connections
  • Designed to be as fast and leightweight as possible

This fork has been heavily modified from the original to reduce allocations, copies, and locking. As such, it's fairly stable, but not guaranteed. However, my game Among Us currently runs on it with over 500k MAU, so that counts for something.


HTML documentation, tutorials and quickstarts from the DarkRift Website here should be relatively accurate; but I doubt the original creator will want support calls for this fork. I can provide some limited support if you create an issue.

I have changed some interfaces in "non-intuitive ways", it is my hope that this example repo will be able to help users get started.

If you want to make improvements, I am open to pull requests. If you find bugs, feel free raise issues.


Building Hazel

To build Hazel open solution file using your favourite C# IDE (I use Visual Studio 2017) and then build as you would any other project.


Tips for using Hazel with Unity

  • Unity doesn't like other threads messing with GameObjects. This isn't a problem for tasks like relaying information. But for tasks like spawning GameObjects on clients or correcting physics, you will want to have a thread safe list of events that are run and cleared during Update or FixedUpdate.
    • A List+lock(object) is fine because you have many writers, one reader and Hazel doesn't guarantee event order.
    • A ConcurrentBag is not a bad choice, but you will have to do something special to keep the Update method from hanging if you get an overwhelming number of new events (which suggests problems with your code elsewhere).
  • I also recommend using the ConnectAsync method in a Coroutine that waits for State to change so you don't hang the game while connecting.

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.