kalombo
kalombo

Reputation: 869

How may i use different urls in twisted autobahn?

I need something like in tornado. Each Websocket Handler for each url. For example, I have different urls: ws://localhost/url1, ws://localhost/url2 and i need separate handler for each of them. Is it possible? I tried to set url in WebSocketServerFactory but it didn't work.

Upvotes: 1

Views: 468

Answers (1)

oberstet
oberstet

Reputation: 22051

You can have it either by mapping the requested URL by overriding WebSocketServerProtocol.onConnect or by setting up a Twisted Web resource tree that has specific handlers.

Please see https://github.com/crossbario/autobahn-python/tree/master/examples/twisted/websocket/multiproto for complete examples of both approaches.

Upvotes: 3

Related Questions