docs: move direction matrix to root readme.md

This commit is contained in:
2026-09-28 02:05:40 +01:00
parent cca07468d5
commit 9a9667c480
2 changed files with 20 additions and 15 deletions
+19
View File
@@ -57,6 +57,25 @@ try {
## How it works ## How it works
### Directions
Every call goes from an `emit*` method in one environment to the matching `on*` listener in another. The last column is the [shared-types](../shared-types/readme.md) interface that types it
| From | Call | To | Listener | Typed by |
| ------- | ------------------------------------- | ----------- | ------------------------------------- | ------------------------- |
| server | `emitClient(player, event, ...args)` | client | `onServer` | `RPCEvents_ServerClient` |
| server | `emitClientEveryone(event, ...args)` | all clients | `onServer`, no response | `RPCEvents_ServerClient` |
| server | `emitWebview(player, event, ...args)` | webview | `onServer`, via client | `RPCEvents_ServerWebview` |
| server | `emitSelf(event, ...args)` | server | `onSelf` | `RPCEvents_Server` |
| client | `emitServer(event, ...args)` | server | `onClient`, player first | `RPCEvents_ClientServer` |
| client | `emitWebview(event, ...args)` | webview | `onClient` | `RPCEvents_ClientWebview` |
| client | `emitSelf(event, ...args)` | client | `onSelf` | `RPCEvents_Client` |
| webview | `emitServer(event, ...args)` | server | `onWebview`, player first, via client | `RPCEvents_WebviewServer` |
| webview | `emitClient(event, ...args)` | client | `onWebview` | `RPCEvents_WebviewClient` |
| webview | `emitSelf(event, ...args)` | webview | `onSelf` | `RPCEvents_Webview` |
Commands registered with `onCommand` are typed by `RPCCommands_Server` and `RPCCommands_Client`
### Routing ### Routing
Server and client talk over FiveM network events, client and webview over NUI messages and NUI callbacks. Webview and server never talk directly: every call between them is relayed by the client of that player. So every client must run `createRPC({ env: 'client' })`, even with no listeners of its own, or those calls time out Server and client talk over FiveM network events, client and webview over NUI messages and NUI callbacks. Webview and server never talk directly: every call between them is relayed by the client of that player. So every client must run `createRPC({ env: 'client' })`, even with no listeners of its own, or those calls time out
+1 -15
View File
@@ -51,21 +51,7 @@ See the [main readme](../readme.md#installation). The declaration file below imp
## Interfaces ## Interfaces
Each interface is one direction. An interface you leave empty stays loose (any name, arguments and result), so you can declare them one at a time Each interface types one direction, see the [direction table](../rpc/readme.md#directions) for which `emit*` and `on*` methods use it. `RPCCommands_Server` and `RPCCommands_Client` type `onCommand`. An interface you leave empty stays loose (any name, arguments and result), so you can declare them one at a time
| Interface | Direction | Caller | Listener |
| ------------------------- | ------------------ | ------------------------------------------- | -------------------- |
| `RPCEvents_Client` | client -> client | `emitSelf` (client) | `onSelf` (client) |
| `RPCEvents_ClientServer` | client -> server | `emitServer` (client) | `onClient` (server) |
| `RPCEvents_ClientWebview` | client -> webview | `emitWebview` (client) | `onClient` (webview) |
| `RPCEvents_Server` | server -> server | `emitSelf` (server) | `onSelf` (server) |
| `RPCEvents_ServerClient` | server -> client | `emitClient`, `emitClientEveryone` (server) | `onServer` (client) |
| `RPCEvents_ServerWebview` | server -> webview | `emitWebview` (server) | `onServer` (webview) |
| `RPCEvents_Webview` | webview -> webview | `emitSelf` (webview) | `onSelf` (webview) |
| `RPCEvents_WebviewClient` | webview -> client | `emitClient` (webview) | `onWebview` (client) |
| `RPCEvents_WebviewServer` | webview -> server | `emitServer` (webview) | `onWebview` (server) |
| `RPCCommands_Client` | - | - | `onCommand` (client) |
| `RPCCommands_Server` | - | - | `onCommand` (server) |
- events: the member name is the event name, its parameters are the arguments, its return type is what `emit*` resolves with. Server `onClient` and `onWebview` listeners get the player id before the declared arguments. Names that are not identifiers work too: `'buy-item'(item: string): boolean` - events: the member name is the event name, its parameters are the arguments, its return type is what `emit*` resolves with. Server `onClient` and `onWebview` listeners get the player id before the declared arguments. Names that are not identifiers work too: `'buy-item'(item: string): boolean`
- commands: the key is the command name, the value is not used (`true`) - commands: the key is the command name, the value is not used (`true`)