Registering callbacks for events in Shiny

I am wondering if there is a way to register custom callbacks to events into Shiny's session for when a certain event is fired on the UI, Shiny knows how to handle this. I currently have a web component that opens up a websocket connection (I'd like to connect this to the Shinys session's port). Is there a way to send messages back and forth over this websocket without using the session$sendCustomMessage(type, message) in the server function, and Shiny.addCustomMessageHandler(type, function(message) {...}) on the UI?