Autobahn WebSocket
我正在评估并搭建一个简单的 websocket 服务器,使用的是 autobahn websocket。
有没有人使用过子类 WrappingWebSocketServerProtocol,有没有这方面的使用例子?这个实现相比于 WebSocketServerProtocol 有什么好处?需要重写或实现哪些子方法?
谢谢!
2 个回答
0
找到了几个例子的答案,如果有人感兴趣的话,可以看看:
https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/wrapping
3
AutobahnPython 让你可以在 WebSocket 上运行任何基于流的传输协议的应用,比如 Telnet、IMAP、VNC 等等。为了实现这种封装,你需要使用 WrappingWebSocketServerProtocol
以及相关的类。
此外,AutobahnPython 还支持在任何基于流的传输协议上运行 WebSocket,比如 Unix 域套接字、管道、串口等等。为此,你可以使用 Endpoints:https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo_endpoints
不过,上面提到的两种方式都是针对特定的使用场景。如果你想做一个“正常”的 WebSocket 应用,只需要使用 WebSocketServerProtocol
和相关的类就可以了。