mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
68be4dbbaf
Since the finalize function will get a invalid pointer of WebSocket, invoking ws->closeAysnc() will generate unknown result, probably crash. HOW TO FIX: WebSocket and JSB_WebSocketDelegate inhert from Ref. After websocket is initialized successfully, retain websocket instance and delegate, they will both have 2 reference count. release their reference both in onClose callback and finalize function. The reason is that the order of invoking onClose and finalize function will be unpredictable, ref count technique help to handle this. Another fix is sending onclose event after onerror is received.