license + typos
parent
62c78ea30f
commit
3d45758eef
@ -87,7 +87,7 @@ rpc.unregister('playerDamage')
|
|||||||
```
|
```
|
||||||
|
|
||||||
## callClient
|
## callClient
|
||||||
Calls a client-side event from server or browser
|
Calls a client-side event from server or browser (or client, but better use [call](#call))
|
||||||
|
|
||||||
From browser:
|
From browser:
|
||||||
```ts
|
```ts
|
||||||
@ -103,7 +103,7 @@ rpc.callClient(player, 'updatePlayerData', ['argument']).then(response => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
## callServer
|
## callServer
|
||||||
Calls a server-side event from browser or client
|
Calls a server-side event from browser or client (or server, but better use [call](#call))
|
||||||
```ts
|
```ts
|
||||||
rpc.callServer('updatePlayerData', ['argument']).then(response => {
|
rpc.callServer('updatePlayerData', ['argument']).then(response => {
|
||||||
console.log(`Received: ${response}`)
|
console.log(`Received: ${response}`)
|
||||||
@ -111,7 +111,7 @@ rpc.callServer('updatePlayerData', ['argument']).then(response => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
## callBrowser
|
## callBrowser
|
||||||
Calls a server-side event from browser or client
|
Calls a browser-side event from server or client (or browser, but better use [call](#call))
|
||||||
|
|
||||||
From client:
|
From client:
|
||||||
```ts
|
```ts
|
||||||
@ -119,7 +119,7 @@ rpc.callBrowser('updatePlayerData', ['argument']).then(response => {
|
|||||||
console.log(`Received: ${response}`)
|
console.log(`Received: ${response}`)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
From client (requires player):
|
From server (requires player):
|
||||||
```ts
|
```ts
|
||||||
rpc.callBrowser(player, 'updatePlayerData', ['argument']).then(response => {
|
rpc.callBrowser(player, 'updatePlayerData', ['argument']).then(response => {
|
||||||
console.log(`Received: ${response}`)
|
console.log(`Received: ${response}`)
|
||||||
@ -139,4 +139,9 @@ These should be clear enough themselves, in other cases refer to here
|
|||||||
- ``EVENT_NOT_REGISTERED`` - throws in Promise (rejects) in called environment when event is either already unregistered or not registered yet. If you see this its almost always calling an event before registering
|
- ``EVENT_NOT_REGISTERED`` - throws in Promise (rejects) in called environment when event is either already unregistered or not registered yet. If you see this its almost always calling an event before registering
|
||||||
- ``UNKNOWN_ENVIRONMENT`` - throws in any environment that is not recognized as server/client/browser in Rage. Unlike ``rage-rpc`` this is not thrown in browser when launched without mp context IF you specify it in browser rpc options (see Options)
|
- ``UNKNOWN_ENVIRONMENT`` - throws in any environment that is not recognized as server/client/browser in Rage. Unlike ``rage-rpc`` this is not thrown in browser when launched without mp context IF you specify it in browser rpc options (see Options)
|
||||||
- ``NO_BROWSER`` - throws on client if you failed to specify valid browser for it to refer to when calling browser
|
- ``NO_BROWSER`` - throws on client if you failed to specify valid browser for it to refer to when calling browser
|
||||||
- ``EVENT_RESPONSE_TIMEOUT`` - throws in Promise (rejects) when failed to receive a response data from called environment. You may not always want to receive it at all, for now it just works like this. Prefer adding ``catch`` on your events
|
- ``EVENT_RESPONSE_TIMEOUT`` - throws in Promise (rejects) when failed to receive a response data from called environment. You may not always want to receive it at all, for now it just works like this. Prefer adding ``catch`` on your events
|
||||||
|
|
||||||
|
# License
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Entity Seven Group
|
Loading…
Reference in New Issue
Block a user