Skip to content

JollyPixel

💃 Getting Started ​

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

bash
$ npm i @jolly-pixel/network
# or
$ yarn add @jolly-pixel/network

👀 Usage example ​

Vite server ​

ts
import * as network from "@jolly-pixel/network";
import {
  createWebSocketNetworkPlugin
} from "@jolly-pixel/network/node";

export default {
  plugins: [
    createWebSocketNetworkPlugin({
      extensions: [
        new network.PresenceOnlyExtension("echo", "echo", {
          broadcast: true
        })
      ]
    })
  ]
};

Browser client ​

ts
import * as network from "@jolly-pixel/network/client";

const client = new network.Client();
const room = client.room("echo");

room.on("message", (payload) => console.log(payload));
room.on("peer-joined", (event) => console.log(`${event.clientId} joined`));
room.on("peer-left", (event) => console.log(`${event.clientId} left`));
room.join();
room.send({ hello: "world" });

📖 Guides ​

📚 API ​

Client ​

Import from @jolly-pixel/network/client.

Server ​

Import from @jolly-pixel/network; Node.js hosting comes from @jolly-pixel/network/node.

Protocol ​

Shared by both sides.

In-process transports ​

📈 Benchmarks ​

bash
$ pnpm --filter @jolly-pixel/network bench
$ pnpm --filter @jolly-pixel/network bench:load --scenario command --clients 150

bench runs the micro suites in bench/*.bench.ts (--allocations adds B/op). bench:load drives a server over real WebSockets; --help lists the scenarios and options.

✨ Contributors guide ​

Read the contributing guide before submitting a change.

Once you have finished your development, check that the tests (and linter) are still good by running the following script:

bash
$ pnpm run test
$ pnpm run lint

CAUTION

In case you introduce a new feature or fix a bug, make sure to include tests for it as well.

📃 License ​

MIT