Commit Graph

25 Commits

Author SHA1 Message Date
Linden
8509867abd refactor(callback/client): require source in response handler 2025-03-18 02:39:41 +11:00
Linden
b726faea2d feat(callback): implement callback validation
Prevent callbacks from being overwritten by other resources.
Throw an immediate error if the callback does not exist.
2025-02-03 15:41:58 +11:00
Linden
99fb752d30 fix(callback): support __call metatables as cb function
Resolves #668.
2025-01-20 02:10:09 +11:00
Linden
2909cb5db6 refactor(callback): warn if callback function is nil/false
Between the headache of people misusing callbacks
and people complaining about third-party resources
that misused them, I would rather just shut them up.

I'll just deprecate this crap at some point anyway.
2024-05-23 09:41:24 +10:00
Linden
f0009f0bc8 refactor(callback): assertions
Both client and server callbacks will check if "cb" is a function, to
reduce the number of people using callbacks as a replacement for
events.

Server->client callbacks will now check if the target playerId exists,
as people apparently use it for unintended values (i.e. -1).
2024-05-22 16:36:22 +10:00
Linden
a40be54a9e refactor(callback): increase default timeout 2024-05-21 05:50:06 +10:00
Linden
2166b076da feat(callback): add timeout to callback events
Should help when people await broken or unregistered events.
Defaults to 60 seconds, adjusted with convar ox:callbackTimeout.
2024-05-03 15:49:33 +10:00
Linden
02d935237d fix(client/callback): mark delay as optional 2023-09-16 22:11:23 +10:00
Linden
250cd56896 fix(callback): return types 2023-02-06 13:22:19 +11:00
Linden
124a5f15ba refactor(imports/callback): response varargs
Trying to have scrt compatible responses gets weird when using
msgpack.
2022-12-13 08:26:43 +11:00
Linden
03dcf14f7e fix(callback): multi-return values for callback method
Resolves #136
2022-10-25 03:03:03 +11:00
Linden
2bb0d68415 fix(callback): bad argument to unpack when callback throws error
Throwing an error responds with false rather than a string.
2022-10-19 20:20:38 +11:00
Linden
b05594e77f fix(callback): pack nil values
See #117
2022-10-08 22:20:46 +11:00
Linden
863ac03ca3 refactor(imports): more type fixes 2022-09-14 16:12:43 +10:00
Linden
26538b8148 refactor(imports): assign modules directly to lib namespace
Mostly a change for improved intellisense with sumneko lua.
Includes some type fixes and deprecation notices.
2022-09-14 01:20:50 +10:00
Linden
ed7bf536e8 feat(resource): load callbacks
Load lib.callback for internal use.
2022-09-14 00:52:10 +10:00
Linden
2a1815c460 tweak(callback): error handling
Errors during callbacks will never respond, so we'll use a protected call
and format the error message with a normal print to keep the thread
alive.
2022-08-25 18:49:07 +10:00
Linden
245af3df41 refactor(callback): types 2022-08-08 17:16:57 +10:00
Linden
e95ae858df fix(callback): handle external resource events
Calling registered callback events in another resource should respond to
the invoking resource.
2022-06-19 13:08:28 +10:00
Linden
76fcc007c4 feat(callback): client callback
Allow the client to listen for and respond to server requests.
Basically just copy-paste and swap the two.
2022-06-09 05:18:05 +10:00
Linden
c85e9032f9 refactor(callback): rewrite
Register a single net event to handle callback responses (per resource).
Previous implementation registered new events for each callback.
2022-06-09 04:43:37 +10:00
Linden
3acc70f32a fix(callback): incorrect param definition 2022-03-10 14:23:25 +00:00
Linden
5c157db3e5 fix(callback): incorrect args in __call method 2022-03-04 10:35:14 +11:00
Linden
4ae20d4dad refactor(imports/callback): new syntax
BREAKING!
2022-02-28 17:17:05 +11:00
Linden
aeccbece09 refactor: rename imports
BREAKING!
Since the folder name determines the import name (i.e. lib.callbacks), use better names and lowerCamelCase.
2022-02-28 16:30:58 +11:00