MCPcopy
hub / github.com/felixrieseberg/windows95 / push

Method push

src/renderer/smb/netbios.ts:21–49  ·  view source on GitHub ↗
(chunk: Uint8Array)

Source from the content-addressed store, hash-verified

19 private buf = new Uint8Array(0);
20
21 push(chunk: Uint8Array): NBMessage[] {
22 // append
23 const merged = new Uint8Array(this.buf.length + chunk.length);
24 merged.set(this.buf);
25 merged.set(chunk, this.buf.length);
26 this.buf = merged;
27
28 const out: NBMessage[] = [];
29 while (this.buf.length >= 4) {
30 const type = this.buf[0];
31 // length is 17-bit: high bit of byte 1, then bytes 2-3 big-endian
32 const len = ((this.buf[1] & 0x01) << 16) | (this.buf[2] << 8) | this.buf[3];
33 const total = 4 + len;
34 if (this.buf.length < total) break;
35
36 const frame = this.buf.subarray(0, total);
37 this.buf = this.buf.slice(total);
38
39 if (type === NB_SESSION_REQUEST) {
40 out.push({ type: NB_SESSION_REQUEST });
41 } else if (type === NB_SESSION_MESSAGE) {
42 out.push({ type: NB_SESSION_MESSAGE, payload: frame.slice(4) });
43 } else if (type === NB_SESSION_KEEPALIVE) {
44 out.push({ type: NB_SESSION_KEEPALIVE });
45 }
46 // anything else: drop
47 }
48 return out;
49 }
50}
51
52export function nbPositiveResponse(): Uint8Array {

Callers 15

armVgaTraceFunction · 0.45
sendKeysMethod · 0.45
chainFunction · 0.45
waFunction · 0.45
libv86.jsFile · 0.45
QaFunction · 0.45
ZaFunction · 0.45
cbFunction · 0.45
ebFunction · 0.45
fbFunction · 0.45
GbFunction · 0.45
HbFunction · 0.45

Calls 1

setMethod · 0.45

Tested by

no test coverage detected