MCPcopy
hub / github.com/nirui/sshwifty / handleClose

Method handleClose

ui/stream/streams.js:354–379  ·  view source on GitHub ↗

* handle received close respond * * @param {header.Header} hd The header * * @throws {Exception} when given stream is not running *

(hd)

Source from the content-addressed store, hash-verified

352 *
353 */
354 async handleClose(hd) {
355 if (hd.data() >= this.streams.length) {
356 return;
357 }
358
359 let stream = this.streams[hd.data()];
360
361 if (!stream.running()) {
362 // WARNING: Connection must be reset at this point because we cannot
363 // determine how many bytes to read
364 throw new Exception(
365 'Remote is requesting for stream "' +
366 hd.data() +
367 '" to be closed, but the stream is not running',
368 false
369 );
370 }
371
372 let cResult = await stream.close();
373
374 let completedHeader = new header.Header(header.COMPLETED);
375 completedHeader.set(hd.data());
376 this.sender.send(new Uint8Array([completedHeader.value()]));
377
378 return cResult;
379 }
380
381 /**
382 * handle received close respond

Callers 1

tickMethod · 0.95

Calls 6

setMethod · 0.95
valueMethod · 0.95
dataMethod · 0.45
runningMethod · 0.45
closeMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected