Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort pending call #3

Open
xxshady opened this issue Oct 25, 2023 · 0 comments
Open

Abort pending call #3

xxshady opened this issue Oct 25, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@xxshady
Copy link
Owner

xxshady commented Oct 25, 2023

Use case example: player position setter with preloading textures of area

Serverside

// for this example, we dont care what happens with this promise
rpc.emitClient(player, 'loadArea', new alt.Vector3(0, 0, 72))

rpc.abortPendingClientEmit(player, 'loadArea') // if pending, promise of previous call will be rejected

await rpc.emitClient(player, 'loadArea', new alt.Vector3(222, 222, 222)) // another random location
player.pos = new alt.Vector3(222, 222, 222)

Clientside (nothing really changes here):

rpc.onServer('loadArea', async (pos) => {
  await alt.Utils.loadMapArea(pos)
})

Implementation details:

It may need addition of unique ID for each rpc call because client may send response of aborted rpc back to server when server aborted previous call and already called same rpc name again

@xxshady xxshady added the enhancement New feature or request label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant