UnityWebSocket
UnityWebSocket copied to clipboard
:whale: The Best Unity WebSocket Plugin for All Platforms.
I'm using version 2.6.4 connect to my wss server it's said "Unable to connect to the remote server" and then when I switch my server to ws it work normally.
导入会方便一些,免于文件传来传去麻烦。 https://docs.unity3d.com/Manual/upm-ui-giturl.html https://docs.unity3d.com/Manual/upm-git.html#syntax
 在SendBufferAsync的163行sendQueue.Enqueue(buffer); 把消息压进队列的时候 下面的SendTask()线程可能已经退出了 导致消息需要到下次发送其他消息的时候 才会一起发送
 要先判断Blob是否undefined,否则会报错,然后接收字符串就走不到下面的判断分支
Bug fixed: The "onMessageStr" callback is missed in original code. And the callback function signature is also mistyped.
004.framework.js.br:9 Uncaught ReferenceError: buffer is not defined at _WebSocketSend (004.framework.js.br:9:144574) at 004.wasm.br:0x38622a9 at invoke_iiii (004.framework.js.br:9:419715) at 004.wasm.br:0x2b6843a at 004.wasm.br:0x38622f0 at invoke_iiiii (004.framework.js.br:9:420026) at 004.wasm.br:0x2b682ac at 004.wasm.br:0x38622fe at invoke_viii (004.framework.js.br:9:419865) at...
为什么Error事件需要等很久才抛出来?
* Added PooledBuffer to improve memory performance 添加buffer池优化内存性能 目前在Editor/WebGL版本使用Profiler测试,buffer池足够可用时收发消息GC.Alloc稳定为0 * Disable WebGL Blob to prevent listener multiple allocations WebGL中修改 `instance.ws.binaryType = 'arraybuffer';`强制使用arraybuffer而不是Blob来规避每次收消息new FileReader设置listener Chrome performance中会发现稳定的listener的增加和一段时间后GC, 暂时强制使用arraybuffer进行规避 我这使用Unity2021.3版本测试WebGL build, 即使Profiler中GC.Alloc为0, 在Chrome...
目前自己是这么改造的
不需要保留Blob数据格式了,只支持ArrayBuffer即可,效率更高。 instance.ws.binaryType = "arraybuffer";