UNPKG

@needle-tools/networking

Version:
42 lines (31 loc) 1.43 kB
This is the networking package for [Needle Engine](https://needle.tools) --- ### Integrate with fastify: ```js import networking from "@needle-tools/needle-tiny-networking-ws"; networking.startServerFastify(fastifyApp, { endpoint: "/socket" }); ``` ### Integrate with express: ```js import networking from "@needle-tools/needle-tiny-networking-ws"; networking.startServerExpress(expressApp, { endpoint: "/socket" }); ``` ### Options - `endpoint : string` - optional relative server endpoint (e.g. `/socket` to start the websocket endpoint on `yourserver/socket`). If not provided will fallback to `/` - `maxUsers: number` - max concurrent users on a server ### Storage The networking state can be saved to S3 compatible storage providers. Use the following environment variables to enable S3 storage: ```bash NEEDLE_NETWORKING_S3_ENDPOINT= NEEDLE_NETWORKING_S3_REGION= NEEDLE_NETWORKING_S3_BUCKET= NEEDLE_NETWORKING_S3_ACCESS_KEY_ID= NEEDLE_NETWORKING_S3_ACCESS_KEY= NEEDLE_NETWORKING_S3_PREFIX= # all state saved in the bucket will be prefixed with this string. This can be a path e.g. `my_state/` or a unique id `server_123_` ``` ## Contact <b>[needle — tools for unity](https://needle.tools)</b> • [@NeedleTools](https://twitter.com/NeedleTools) • [@marcel_wiessler](https://twitter.com/marcel_wiessler) • [@hybridherbst](https://twitter.com/hybridherbst)