Dynamic Phoenix routes using ETS with sockets and channels

I found a code to dynamically register/unregister app routes.
Is it possible to add method to: DynamicDispatch module to register/unregister sockets with multiple channels?

defmodule HelloPhoenix.Router do
    use HelloPhoenix.Web, :router
    
    # from this code:
    # socket "/example", HelloPhoenix do
    #     channel "first:*", FirstChannel
    #     channel "second:*", SecondChannel
    # end
    
    # to new method like:
    # DynamicDispatch.register_socket(:my_app_user_routes, "foo.com", "/example", HelloPhoenix) do
    #   channel "first:*", FirstChannel
    #   channel "second:*", SecondChannel
    # end
end
2 Likes

I find a solution for what I’m looking for. It’s partially solved in this thread. From that point all other things are not a problem.