Skip to content

Conversation

@WolfGangS
Copy link
Contributor

@WolfGangS WolfGangS commented Dec 21, 2025

Description

Adds a method for the web socket server to allow 3rd party tools to query scripts available for subscription. Useful for the sl-vscode-plugin to be able to resubscribe after a connection loss (like the user updated vscode, or similar)

Also useful for plans to add support for a cli version of the plugin, to allow broader editor compatibility.

Related Issues

Issue Link: relates to secondlife/sl-vscode-plugin#43


Checklist

Please ensure the following before requesting review:

  • I have provided a clear title and detailed description for this pull request.
  • If useful, I have included media such as screenshots and video to show off my changes.
  • The PR is linked to a relevant issue with sufficient context.
  • I have tested the changes locally and verified they work as intended.
  • All new and existing tests pass.
  • Code follows the project's style guidelines.
  • Documentation has been updated if needed.
  • Any dependent changes have been merged and published in downstream modules
  • I have reviewed the contributing guidelines.

Additional Notes

Discussed with @Rider-Linden before, so likely more his wheelhouse for review.

I suspect there may be some issue I am missing with my changes to LLScriptEditorWSServer::unsubscribeConnection but they (or something like them) are needed else a websocket connection closing flushes scripts from the subscription list, even though they are still open in viewer, and on disk in the temp directory.

Signed-off-by: WolfGangS <[email protected]>
@akleshchev akleshchev requested a review from marchcat January 6, 2026 16:33
Copy link
Contributor

@marchcat marchcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

return LLSD();
});
script_connection->registerMethod("script.list",
[that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac build complains about unused connection_id here.

error: lambda capture 'connection_id' is not used [-Werror,-Wunused-lambda-capture]
290 | [that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD
Suggested change
[that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD
[that](const std::string&, const LLSD&, const LLSD& params) -> LLSD

Copy link
Contributor

@Rider-Linden Rider-Linden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Marchcat's change and the script unsubscribe list thing.

{
++it;
it->second.mConnectionID = 0;
it->second.mConnection.reset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to leave the dead subscription record in the map....

Copy link
Contributor Author

@WolfGangS WolfGangS Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mSubscriptions is a map of scripts open in sl available to subscribe to, as they don't have a connection set until a websocket connetion subscribes.

Scripts are added when a user presses edit on the in viewer script editor. If they are removed from mSubscriptions when a websocket unsubscribes, then the user has to press edit in sl again to be able to resubscribe to the script.

For external tools to be able to reconnect, the script must still exist in the subscriptions list to subscribe to them.

So this change makes socket unsubscribe only do the inverse of what subscribing does in handleScriptSubscribe,

So the behavior is

  • Add entry to mSubscritpions - Press Edit on in viewer script editor window - subscribeScriptEditor
  • Remove entry from mSubscriptions - Close in viewer script editor window - unsubscribeEditor
  • Set mSubscription connection - Web socket connects and subscribes to script - handleScriptSubscribe
  • Unset mSubscription connection - Web socket unsubscribes or closes. - unsubscribeConnection

If that's not desirable, then this might need a larger rework, to achieve resubscribing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants