Skip to content

Commit

Permalink
fix: Ensure data is only transmitted on open and ready connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjdhjd committed Jul 4, 2024
1 parent 853171f commit 87c9077
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/camera/RecordingManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,10 @@ class CameraRecordingStream extends EventEmitter implements DataStreamProtocolHa
let offset = 0;
let dataChunkSequenceNumber = 1;
while (offset < fragment.length) {
if (this.closed) {
break;
}

const data = fragment.slice(offset, offset + maxChunk);
offset += data.length;

Expand Down
4 changes: 3 additions & 1 deletion src/lib/datastream/DataStreamServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ export class DataStreamConnection extends EventEmitter {
header.protocol = protocol;
header.event = event;

this.sendHDSFrame(header, message);
if (this.state === ConnectionState.READY) {
this.sendHDSFrame(header, message);
}
}

/**
Expand Down

0 comments on commit 87c9077

Please sign in to comment.