Repository navigation
Conversation
A function handed to registerBluetoothDevice from another resource arrives as a function reference (a table with __call), so the type(...) == 'function' check dropped it and the owning script never heard about connections. Accept any callable value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A function handed to
registerBluetoothDevicefrom another resource arrives as a function reference (a table with a__callmetamethod), not a Lua function.bluetooth.validateandsafelyinserver/bluetooth/registry.luaboth checkedtype(fn) == 'function', soonConnectandonDisconnectwere dropped and the owning script never heard about connections. Thesd-phone:server:bluetooth:connected/disconnectedevents still fire, which is how we worked around it.This adds
bluetooth.isCallable(a function, or a table whose metatable has__call) and uses it in both places.Type of Change
Related Issues
None.
Testing
On a live server, two throwaway resources: one exported a function taking a callback, the other passed a function through it. On the receiving side the value was
type=tablewith a metatable carrying__call, and calling it returned the callback's result. That is exactly the shape the old check rejected.The changed files were also run through a Lua parser.
Breaking Changes
None. Plain Lua functions pass as before; values that are neither functions nor callable tables are still ignored.
Checklist