diff --git a/sockets/probe_railgun.js b/sockets/probe_railgun.js index 654265f..4bd962a 100644 --- a/sockets/probe_railgun.js +++ b/sockets/probe_railgun.js @@ -51,24 +51,32 @@ if (Buf.length >= 40) flush(); }; - // ---- ③ WS 上行记录 ---- + // ---- ③ WS 上行记录(游戏发的是 Blob,必须异步读,否则 hex 恒为空)---- + var Hex = function (u) { + var h = ''; + for (var i = 0; i < u.length; i++) h += (u[i] < 16 ? '0' : '') + u[i].toString(16); + return h; + }; try { var W = window.WebSocket; if (W && W.prototype && !W.prototype.__probeWrapped__) { var Orig = W.prototype.send; W.prototype.send = function (d) { try { - if (d && d.byteLength !== undefined) { - var u = new Uint8Array(d.slice ? d.slice(0, 16) : d, 0, Math.min(16, d.byteLength)); - var h = ''; - for (var i = 0; i < u.length; i++) h += (u[i] < 16 ? '0' : '') + u[i].toString(16); - Buf.push('[+' + Now() + 'ms] SEND len=' + d.byteLength + ' hex=' + h); + if (d instanceof Blob) { + var size = d.size; + d.slice(0, 24).arrayBuffer().then(function (ab) { + Buf.push('[+' + Now() + 'ms] SEND blob len=' + size + ' hex=' + Hex(new Uint8Array(ab))); + }).catch(function () {}); + } else if (d && d.byteLength !== undefined) { + var u = new Uint8Array(d.slice ? d.slice(0, 24) : d, 0, Math.min(24, d.byteLength)); + Buf.push('[+' + Now() + 'ms] SEND len=' + d.byteLength + ' hex=' + Hex(u)); } } catch (e) {} return Orig.apply(this, arguments); }; W.prototype.__probeWrapped__ = true; - Buf.push('WS send 已挂(记帧长+前16字节)'); + Buf.push('WS send 已挂(Blob 异步读,记前 24 字节)'); } } catch (e) {}