@inglorious/server 12.0.1 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -89
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
# Inglorious Server
|
|
2
|
-
|
|
3
|
-
A real-time, lightweight server designed to enable multiplayer experiences for games built with the Inglorious Engine. This server is built on Node.js and uses WebSockets to handle real-time communication, ensuring low-latency updates for all connected clients.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Real-Time Communication**: Uses WebSockets to provide bidirectional, low-latency communication between the server and clients.
|
|
8
|
-
- **Server-Authoritative Game State**: Manages a central game state using the `@inglorious/store` and acts as the single source of truth for all clients.
|
|
9
|
-
- **Scalable Architecture**: The server's logic is modular and split into dedicated files for handling game loading, the main game loop, and WebSocket events.
|
|
10
|
-
- **Dynamic Game Loading**: Supports loading game data from a specified JavaScript module, allowing you to easily run different game worlds without changing the server code.
|
|
11
|
-
- **Production-Ready Logging**: Uses `pino` for fast, structured logging, making it easy to monitor and debug in a production environment.
|
|
12
|
-
|
|
13
|
-
## Getting Started
|
|
14
|
-
|
|
15
|
-
### Prerequisites
|
|
16
|
-
|
|
17
|
-
- [Node.js](https://nodejs.org/) (version 22 or higher)
|
|
18
|
-
- [pnpm](https://pnpm.io/) (used for package management)
|
|
19
|
-
|
|
20
|
-
### Installation
|
|
21
|
-
|
|
22
|
-
1. Clone the Inglorious Forge repository:
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
git clone https://github.com/IngloriousCoderz/inglorious-forge.git
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
2. Navigate to the `@inglorious/server` directory:
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
cd packages/server
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
3. Install the dependencies:
|
|
35
|
-
|
|
36
|
-
```sh
|
|
37
|
-
pnpm install
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Usage
|
|
41
|
-
|
|
42
|
-
The server can be started using the `start` or `dev` scripts. You can optionally provide a path to a game module to load a specific game state.
|
|
43
|
-
|
|
44
|
-
### Running in Development Mode
|
|
45
|
-
|
|
46
|
-
To run the server with automatic restarts on file changes, use the `dev` script.
|
|
47
|
-
|
|
48
|
-
```sh
|
|
49
|
-
pnpm dev
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Running in Production Mode
|
|
53
|
-
|
|
54
|
-
To run the server in a production environment, use the `start` script.
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
pnpm start
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Loading a Specific Game
|
|
61
|
-
|
|
62
|
-
By default, the server will attempt to load a `./default-game.js` file. To load a different game, provide the file path as a command-line argument.
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
pnpm start ./path/to/your-game.js
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Project Structure
|
|
69
|
-
|
|
70
|
-
The server's code is split into several files to maintain a clear separation of concerns.
|
|
71
|
-
|
|
72
|
-
- `src/index.js`: The main entry point for the server. It orchestrates the setup of the HTTP and WebSocket servers and initializes the game store and its core handlers.
|
|
73
|
-
- `src/game-loader.js`: Handles the dynamic loading of the initial game state from a JavaScript module. It also includes a fallback state if the game file is not found.
|
|
74
|
-
- `src/game-loop.js`: Contains the core setInterval loop that drives the game logic by calling the store.update() function at a fixed tick rate (60 updates per second).
|
|
75
|
-
- `src/websocket-handler.js`: Manages all WebSocket events, including new connections, incoming messages, and disconnections. It dispatches client events to the store and broadcasts changes to all clients.
|
|
76
|
-
|
|
77
|
-
## Dependencies
|
|
78
|
-
|
|
79
|
-
- `@inglorious/store`: The state management solution for the game engine.
|
|
80
|
-
- `ws`: A simple and fast WebSocket library.
|
|
81
|
-
- `pino`: A highly performant logger for Node.js.
|
|
82
|
-
|
|
83
|
-
## License
|
|
84
|
-
|
|
85
|
-
**MIT License - Free and open source**
|
|
86
|
-
|
|
87
|
-
Created by [Matteo Antony Mistretta](https://github.com/IngloriousCoderz)
|
|
88
|
-
|
|
89
|
-
You're free to use, modify, and distribute this software. See [LICENSE](./LICENSE) for details.
|
|
1
|
+
# Inglorious Server
|
|
2
|
+
|
|
3
|
+
A real-time, lightweight server designed to enable multiplayer experiences for games built with the Inglorious Engine. This server is built on Node.js and uses WebSockets to handle real-time communication, ensuring low-latency updates for all connected clients.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Real-Time Communication**: Uses WebSockets to provide bidirectional, low-latency communication between the server and clients.
|
|
8
|
+
- **Server-Authoritative Game State**: Manages a central game state using the `@inglorious/store` and acts as the single source of truth for all clients.
|
|
9
|
+
- **Scalable Architecture**: The server's logic is modular and split into dedicated files for handling game loading, the main game loop, and WebSocket events.
|
|
10
|
+
- **Dynamic Game Loading**: Supports loading game data from a specified JavaScript module, allowing you to easily run different game worlds without changing the server code.
|
|
11
|
+
- **Production-Ready Logging**: Uses `pino` for fast, structured logging, making it easy to monitor and debug in a production environment.
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
### Prerequisites
|
|
16
|
+
|
|
17
|
+
- [Node.js](https://nodejs.org/) (version 22 or higher)
|
|
18
|
+
- [pnpm](https://pnpm.io/) (used for package management)
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
1. Clone the Inglorious Forge repository:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
git clone https://github.com/IngloriousCoderz/inglorious-forge.git
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Navigate to the `@inglorious/server` directory:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
cd packages/server
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. Install the dependencies:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pnpm install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
The server can be started using the `start` or `dev` scripts. You can optionally provide a path to a game module to load a specific game state.
|
|
43
|
+
|
|
44
|
+
### Running in Development Mode
|
|
45
|
+
|
|
46
|
+
To run the server with automatic restarts on file changes, use the `dev` script.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pnpm dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Running in Production Mode
|
|
53
|
+
|
|
54
|
+
To run the server in a production environment, use the `start` script.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm start
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Loading a Specific Game
|
|
61
|
+
|
|
62
|
+
By default, the server will attempt to load a `./default-game.js` file. To load a different game, provide the file path as a command-line argument.
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
pnpm start ./path/to/your-game.js
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Project Structure
|
|
69
|
+
|
|
70
|
+
The server's code is split into several files to maintain a clear separation of concerns.
|
|
71
|
+
|
|
72
|
+
- `src/index.js`: The main entry point for the server. It orchestrates the setup of the HTTP and WebSocket servers and initializes the game store and its core handlers.
|
|
73
|
+
- `src/game-loader.js`: Handles the dynamic loading of the initial game state from a JavaScript module. It also includes a fallback state if the game file is not found.
|
|
74
|
+
- `src/game-loop.js`: Contains the core setInterval loop that drives the game logic by calling the store.update() function at a fixed tick rate (60 updates per second).
|
|
75
|
+
- `src/websocket-handler.js`: Manages all WebSocket events, including new connections, incoming messages, and disconnections. It dispatches client events to the store and broadcasts changes to all clients.
|
|
76
|
+
|
|
77
|
+
## Dependencies
|
|
78
|
+
|
|
79
|
+
- `@inglorious/store`: The state management solution for the game engine.
|
|
80
|
+
- `ws`: A simple and fast WebSocket library.
|
|
81
|
+
- `pino`: A highly performant logger for Node.js.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
**MIT License - Free and open source**
|
|
86
|
+
|
|
87
|
+
Created by [Matteo Antony Mistretta](https://github.com/IngloriousCoderz)
|
|
88
|
+
|
|
89
|
+
You're free to use, modify, and distribute this software. See [LICENSE](./LICENSE) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "A real-time, lightweight server designed to enable multiplayer experiences for games built with the Inglorious Engine.",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"pino": "^9.9.4",
|
|
42
42
|
"ws": "^8.18.3",
|
|
43
|
-
"@inglorious/store": "
|
|
44
|
-
"@inglorious/utils": "3.7.
|
|
43
|
+
"@inglorious/store": "9.0.1",
|
|
44
|
+
"@inglorious/utils": "3.7.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@inglorious/store": "
|
|
48
|
-
"@inglorious/utils": "3.7.
|
|
47
|
+
"@inglorious/store": "9.0.1",
|
|
48
|
+
"@inglorious/utils": "3.7.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"nodemon": "^3.1.10",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"node": ">= 22"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"format": "prettier --write
|
|
60
|
-
"lint": "eslint .
|
|
59
|
+
"format": "prettier --write .",
|
|
60
|
+
"lint": "eslint .",
|
|
61
61
|
"start": "node src/index.js",
|
|
62
62
|
"dev": "nodemon src/index.js"
|
|
63
63
|
}
|