@javelin/net
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.15 • Public • Published

@javelin/net

Networking protocol and utilities for Javelin ECS.

Overview

Define schema using specialized data types.

const Body = {
  collisionMask: uint8,
  position: {
    x: float64,
    y: float64,
  },
}

Serialize ECS operations and data into ArrayBuffers for transport from server->client.

const producer = createMessageProducer()
producer.attach(entity, body)
producer.detach(entity, spectate)
socket.send(producer.take())

Deserialize and apply messages on the client.

const handler = createMessageHandler()
world.addSystem(handler.system)
socket.on("message", event => handler.push(event.data))

Docs

Read the networking docs to get started.

Package Sidebar

Install

npm i @javelin/net

Weekly Downloads

226

Version

1.0.0-alpha.15

License

MIT

Unpacked Size

236 kB

Total Files

100

Last publish

Collaborators

  • ericmcdaniel