Skip to content

Commit

Permalink
fixup! feat(transport): implement THP
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Jul 30, 2024
1 parent 57e072f commit 6157652
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/transport/src/transports/abstractApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,26 @@ export abstract class AbstractApiTransport extends AbstractTransport {
}
const { path } = getPathBySessionResponse.payload;

const apiWrite = (chunk: Buffer, attemptSignal?: AbortSignal) =>
this.api.write(path, chunk, attemptSignal || signal);
const apiRead = (attemptSignal?: AbortSignal) =>
this.api.read(path, attemptSignal || signal);

try {
const protocol = customProtocol || v1Protocol;

if (protocol.name === 'v2') {
const message = await receiveThpMessage({
messages: this.messages,
protocolState,
apiWrite,
apiRead,
signal,
});

return this.success(message);
}

const message = await receiveAndParse(
this.messages,
() =>
Expand Down

0 comments on commit 6157652

Please sign in to comment.