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

WebSocketController Question #2238

Open
hanygg opened this issue Jan 9, 2025 · 3 comments
Open

WebSocketController Question #2238

hanygg opened this issue Jan 9, 2025 · 3 comments

Comments

@hanygg
Copy link

hanygg commented Jan 9, 2025

I'm having difficulty figuring out how to create a dynamic route, i.e. on the fly as the app is running, for a custom WebSocketController instance.

I want to spin up an instance of the custom web-socket controller with a path determined at run time. It is straightforward to create a web-socket controller when we know the paths in advance but seems to be anything but straightforward for the dynamic case.

It is possible there is a better way to handle this and I am looking for anyone that may of implemented the dynamic case.

I thought I had a solution but I get a runtime assert in the app().run() method for the variable routersInit_ and I don't see anywhere in the framework where this variable gets set to true, so it is very confusing.

Thanks

Created a custom web-socket controller. Removed the ADD_PATH macros. Added a custom registerSelf__(path, {}); within the constructor of the custom web-socket controller.

@Mis1eader-dev
Copy link
Member

There's a websocket path adder with regex, I don't recall the name of the macro though

@hanygg
Copy link
Author

hanygg commented Jan 9, 2025

Yes, that's the approach I decided on. The macro is named WS_ADD_PATH_VIA_REGEX

It doesn't seem to be matching my regular expression however.

@hanygg
Copy link
Author

hanygg commented Jan 9, 2025

I've tried a number of variations of the following. The attempt is to match /ws/<>

WS_ADD_PATH_VIA_REGEX("/securechat/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})");

or

WS_ADD_PATH_VIA_REGEX("/securechat/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");

This should match what I am expecting but it does not. Is there any way to check what the web socket is listening on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants