mudebug-socket

Simulate network conditions


Keywords
mudb, real-time, multiplayer, game, network, failure, simulation
License
MIT
Install
npm install mudebug-socket@0.1.5

Documentation

mudb

mudb is a collection of modules for building realtime client-server networked applications.

TypeScript friendly, works great with Node.js.

WORK IN PROGRESS

table of contents

1 big picture concepts

mudb is a collection of modules for writing realtime distributed applications consisting of many protocols.

1.1 protocols

A protocol, in the mudb sense`, is a collection of related messages and handlers which are grouped according

1.2 messages

Message passing is the basic building block for communication in a distributed system. mudb provides a reliable, ordered message delivery and a faster but unreliable method for sending messages immediately. Messages are strongly typed using user-defined schemas.

1.3 schemas

A schema is a type declaration for the interface between the client and server. Schemas in mudb are specified using the muschema module. Like protocol buffers or gRPC, muschema uses binary serialized messages with a defined schema and makes extensive use of code generation. However, mudb departs from these systems in 3 important ways:

  • Javascript only Unlike protocol buffers, muschema has no aspirations of ever being cross-language. However, it does make it much easier to extend mudb to support direct serialization of custom application specific data structures. For example, you could store all of your objects in an octree and apply a custom schema to directly diff this octree into your own data type.
  • 0-copy delta encoding muschema performs all serialization as a relative diff operation. This means that messages and state changes can be encoded as changes relative to some observed reference. Using relative state changes greatly reduces the amount of bandwidth required to replicate a given change set
  • Memory pools JavaScript is a garbage collected language, and creating patched versions of different messages can generate many temporary objects. In order to avoid needless and wasteful GC thrashing, muschema provides a pooling interface and custom memory allocator.

1.4 abstract sockets

mudb communicates over a generic socket abstraction provided by munet. munet sockets support both reliable and unreliable delivery. Unreliable delivery is used for state replication, while reliable delivery is used for messages. Unreliable delivery is generally faster than reliable delivery since it does not suffer from head-of-line blocking problems. For websocket servers, munet emulates unreliable delivery using multiple websocket connections.

1.5 further reading

Light reading:

Academic references:

2 learning guide

2.1 roadmap

2.2 examples

TODO

3 modules

mudb is implemented as a collection of modules for building realtime networked applications.

3.1 mudb

mudb is the database itself. For users learning the API, start here after reading about concepts.

3.2 muschema

mudb is used to define the database schema.

3.3 protocols

3.3.1 murpc

3.3.2 mustate

TODO

3.4 tools

3.4.1 mudo

mudo is a local development server based on budo which handles a lot of the boilerplate around creating and starting a server/client pair for you.

3.5 socket emulation

3.5.1 mulocal-socket

3.5.2 muweb-socket

3.6 internal

3.6.1 mustreams

credits

Development supported by Shenzhen DianMao Digital Technology Co., Ltd.

codemao logo

Written in Shenzhen, China.

(c) 2017 Mikola Lysenko, Shenzhen DianMao Digital Technology Co., Ltd.