I thought that changing the assigns in the socket would change them everywhere, but as you said earlier, it was wrong since they are copied into channels. So yeah, there is little reason to receive messages in the socket.
Sorry, but I still donāt understand how the example in the comments to id/1 function Test.Web.Endpoint.broadcast "user_socket:#{id}", "disconnect", %{} works.
Where if not in the UserSocket would I implement the disconnecting logic?
The disconnect message is handled internally to the socket. If you want to handle when it disconnects then setup a normal OTP-style monitor, nothing special with that.