• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-js / 11579384597

29 Oct 2024 05:34PM UTC coverage: 84.703% (-0.5%) from 85.23%
11579384597

push

github

web-flow
chore(deps): bump http-proxy-middleware from 2.0.6 to 2.0.7 (#4778)

Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/chimurai/http-proxy-middleware/releases)
- [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.7/CHANGELOG.md)
- [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: http-proxy-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

8186 of 10820 branches covered (75.66%)

Branch coverage included in aggregate %.

20514 of 23063 relevant lines covered (88.95%)

7283.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.17
/libraries/botframework-streaming/src/payloads/streamManager.ts
1
/**
8✔
2
 * @module botframework-streaming
3
 */
4
/**
5
 * Copyright (c) Microsoft Corporation. All rights reserved.
6
 * Licensed under the MIT License.
7
 */
8
import { IHeader } from '../interfaces';
9
import { SubscribableStream } from '../subscribableStream';
10
import { PayloadAssembler } from '../assemblers/payloadAssembler';
2✔
11

12
/**
13
 * Orchestrates and manages streams.
14
 */
15
export class StreamManager {
2✔
16
    private readonly activeAssemblers = [];
113✔
17

18
    /**
19
     * Initializes a new instance of the [StreamManager](xref:botframework-streaming.StreamManager) class.
20
     *
21
     * @param onCancelStream Function to trigger if the managed stream is cancelled.
22
     */
23
    constructor(private readonly onCancelStream: (contentStreamAssembler: PayloadAssembler) => void) {}
113✔
24

25
    /**
26
     * Retrieves a [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) with the given ID if one exists, otherwise a new instance is created and assigned the given ID.
27
     *
28
     * @param id The ID of the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) to retrieve or create.
29
     * @returns The [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) with the given ID.
30
     */
31
    getPayloadAssembler(id: string): PayloadAssembler {
32
        if (!this.activeAssemblers[id]) {
62!
33
            // A new id has come in, kick off the process of tracking it.
34
            const assembler = new PayloadAssembler(this, { id });
44✔
35
            this.activeAssemblers[id] = assembler;
44✔
36

37
            return assembler;
44✔
38
        } else {
39
            return this.activeAssemblers[id];
18✔
40
        }
41
    }
42

43
    /**
44
     * Retrieves the [SubscribableStream](xref:botframework-streaming.SubscribableStream) from the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) this manager manages.
45
     *
46
     * @param header The Header of the [SubscribableStream](xref:botframework-streaming.SubscribableStream) to retrieve.
47
     * @returns The [SubscribableStream](xref:botframework-streaming.SubscribableStream) with the given header.
48
     */
49
    getPayloadStream(header: IHeader): SubscribableStream {
50
        const assembler = this.getPayloadAssembler(header.id);
22✔
51

52
        return assembler.getPayloadStream();
22✔
53
    }
54

55
    /**
56
     * Used to set the behavior of the managed [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) when data is received.
57
     *
58
     * @param header The Header of the stream.
59
     * @param contentStream The [SubscribableStream](xref:botframework-streaming.SubscribableStream) to write incoming data to.
60
     * @param contentLength The amount of data to write to the contentStream.
61
     */
62
    onReceive(header: IHeader, contentStream: SubscribableStream, contentLength: number): void {
63
        if (!this.activeAssemblers[header.id]) {
24!
64
            return;
2✔
65
        }
66
        this.activeAssemblers[header.id].onReceive(header, contentStream, contentLength);
22✔
67
    }
68

69
    /**
70
     * Closes the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) assigned to the [SubscribableStream](xref:botframework-streaming.SubscribableStream) with the given ID.
71
     *
72
     * @param id The ID of the [SubscribableStream](xref:botframework-streaming.SubscribableStream) to close.
73
     */
74
    closeStream(id: string): void {
75
        if (!this.activeAssemblers[id]) {
12!
76
            return;
10✔
77
        } else {
78
            const assembler: PayloadAssembler = this.activeAssemblers[id];
2✔
79
            this.activeAssemblers.splice(this.activeAssemblers.indexOf(id), 1);
2✔
80
            const targetStream = assembler.getPayloadStream();
2✔
81
            if ((assembler.contentLength && targetStream.length < assembler.contentLength) || !assembler.end) {
2!
82
                this.onCancelStream(assembler);
2✔
83
            }
84
        }
85
    }
×
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc