txWS
txWS copied to clipboard
Feature request: access original URL
I'm not sure this is possible (I experimented) with the current library, so am assuming this is more a feature-request. Basically I'd like to get the original URL, which is parsed on line 610 of the request, but not made accessible to my protocol or factory verb, self.location, version = request.split(" ")
Reason, is that I would like to use the URL as a type of sub-protocol router. In meantime I will just have my ws client send the necessary information over the ws, but still I think this could be nice to have.
Here's my init code by the way:
listen_str = 'ssl:%s:privateKey=%s:certKey=%s' % (port, key, cert)
listen(listen_str, WebSocketFactory(MyFactory))
FYI, the information is available from the protocol as self.transport.location
. The catch is that you're not notified when it becomes available; I worked around this by making sure the client always sent a message as soon as it connected and checking the URL in dataReceived
.
I agree there should be a notification when the URL has come in, but I understand @MostAwesomeDude intends to deprecate txWS in favor of upcoming WebSocket support in Twisted itself.