diff --git a/sockets/probe_railgun.js b/sockets/probe_railgun.js index 4bd962a..a99abcf 100644 --- a/sockets/probe_railgun.js +++ b/sockets/probe_railgun.js @@ -69,8 +69,18 @@ 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)); + // 注意:游戏实际发的是 DataView / TypedArray / ArrayBuffer(实测 DataView), + // 且有 .byteLength 但没有 .slice —— 必须走 buffer+byteOffset 取视图, + // 否则 new Uint8Array(dataView, 0, 24) 会得到长度 0 的视图(hex 恒为空)。 + var View; + if (d.buffer && typeof d.byteOffset === 'number') { + View = new Uint8Array(d.buffer, d.byteOffset, Math.min(24, d.byteLength)); + } else if (typeof d.slice === 'function') { + View = new Uint8Array(d.slice(0, 24)); + } else { + View = new Uint8Array(d, 0, Math.min(24, d.byteLength)); + } + Buf.push('[+' + Now() + 'ms] SEND len=' + d.byteLength + ' hex=' + Hex(View)); } } catch (e) {} return Orig.apply(this, arguments);