Skip to content

Latest commit

 

History

History

net

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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