2 回答

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個(gè)贊
我覺得文檔有點(diǎn)不清楚,這就是解決方案,也做了公關(guān)。
class ModelConsumerObserver(AsyncAPIConsumer):
async def accept(self, **kwargs):
await super().accept()
await self.model_change.subscribe()
@model_observer(models.Test)
async def model_change(self, message, **kwargs):
await self.send_json(message)
從那時(shí)起,websocket 會(huì)將模型更改推送給客戶端

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊
我覺得文檔有點(diǎn)不清楚,這就是解決方案,也做了公關(guān)。
class ModelConsumerObserver(AsyncAPIConsumer):
async def accept(self, **kwargs):
await super().accept()
await self.model_change.subscribe()
@model_observer(models.Test)
async def model_change(self, message, **kwargs):
await self.send_json(message)
從那時(shí)起,websocket 會(huì)將模型更改推送給客戶端
添加回答
舉報(bào)