• 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

85.71
/libraries/botframework-streaming/src/protocolAdapter.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 { PayloadAssembler } from './assemblers/payloadAssembler';
9
import { PayloadAssemblerManager } from './payloads/payloadAssemblerManager';
2✔
10
import { RequestManager } from './payloads/requestManager';
11
import { SendOperations } from './payloads/sendOperations';
2✔
12
import { StreamManager } from './payloads/streamManager';
2✔
13
import { PayloadReceiver } from './payloadTransport/payloadReceiver';
14
import { PayloadSender } from './payloadTransport/payloadSender';
15
import { RequestHandler } from './requestHandler';
16
import { SubscribableStream } from './subscribableStream';
17
import { StreamingRequest } from './streamingRequest';
18
import { generateGuid } from './utilities/protocol-base';
2✔
19
import { IReceiveResponse, IReceiveRequest } from './interfaces';
20
import { IHeader } from './interfaces/IHeader';
21

22
/**
23
 * Creates a protocol adapter for Streaming.
24
 */
25
export class ProtocolAdapter {
2✔
26
    private readonly requestHandler: RequestHandler;
27
    private readonly payloadSender: PayloadSender;
28
    private readonly payloadReceiver: PayloadReceiver;
29
    private readonly requestManager: RequestManager;
30
    private readonly sendOperations: SendOperations;
31
    private readonly streamManager: StreamManager;
32
    private readonly assemblerManager: PayloadAssemblerManager;
33

34
    /**
35
     * Creates a new instance of the protocol adapter class.
36
     *
37
     * @param requestHandler The [RequestHandler](xref:botframework-streaming.RequestHandler) that will process incoming requests.
38
     * @param requestManager The [RequestManager](xref:botframework-streaming.RequestManager) that will process outgoing requests.
39
     * @param sender The [PayloadSender](xref:botframework-streaming.PayloadSender) for use with outgoing requests.
40
     * @param receiver The [PayloadReceiver](xref:botframework-streaming.PayloadReceiver) for use with incoming requests.
41
     */
42
    constructor(
43
        requestHandler: RequestHandler,
44
        requestManager: RequestManager,
45
        sender: PayloadSender,
46
        receiver: PayloadReceiver
47
    ) {
48
        this.requestHandler = requestHandler;
89✔
49
        this.requestManager = requestManager;
89✔
50
        this.payloadSender = sender;
89✔
51
        this.payloadReceiver = receiver;
89✔
52
        this.sendOperations = new SendOperations(this.payloadSender);
89✔
53
        this.streamManager = new StreamManager(this.onCancelStream);
89✔
54
        this.assemblerManager = new PayloadAssemblerManager(
89✔
55
            this.streamManager,
56
            (id: string, response: IReceiveResponse): Promise<void> => this.onReceiveResponse(id, response),
8✔
57
            (id: string, request: IReceiveRequest): Promise<void> => this.onReceiveRequest(id, request)
12✔
58
        );
59
        this.payloadReceiver.subscribe(
89✔
60
            (header: IHeader): SubscribableStream => this.assemblerManager.getPayloadStream(header),
40✔
61
            (header: IHeader, contentStream: SubscribableStream, contentLength: number): void =>
62
                this.assemblerManager.onReceive(header, contentStream, contentLength)
36✔
63
        );
64
    }
65

66
    /**
67
     * Sends a request over the attached request manager.
68
     *
69
     * @param request The outgoing request to send.
70
     * @returns The response to the specified request.
71
     */
72
    async sendRequest(request: StreamingRequest): Promise<IReceiveResponse> {
×
73
        const requestId: string = generateGuid();
20✔
74

75
        // Register the request in the request manager before sending it to the server.
76
        // Otherwise, if the server respond quickly, it may miss the request.
77
        const getResponsePromise = this.requestManager.getResponse(requestId);
20✔
78

79
        await this.sendOperations.sendRequest(requestId, request);
20✔
80

81
        return getResponsePromise;
20✔
82
    }
83

84
    /**
85
     * Executes the receive pipeline when a request comes in.
86
     *
87
     * @param id The id the resources created for the response will be assigned.
88
     * @param request The incoming request to process.
89
     */
90
    async onReceiveRequest(id: string, request: IReceiveRequest): Promise<void> {
×
91
        if (this.requestHandler) {
14✔
92
            const response = await this.requestHandler.processRequest(request);
14✔
93

94
            if (response) {
10!
95
                await this.sendOperations.sendResponse(id, response);
10✔
96
            }
97
        }
98
    }
99

100
    /**
101
     * Executes the receive pipeline when a response comes in.
102
     *
103
     * @param id The id the resources created for the response will be assigned.
104
     * @param response The incoming response to process.
105
     */
106
    async onReceiveResponse(id: string, response: IReceiveResponse): Promise<void> {
×
107
        await this.requestManager.signalResponse(id, response);
10✔
108
    }
109

110
    /**
111
     * Executes the receive pipeline when a cancellation comes in.
112
     *
113
     * @param contentStreamAssembler The payload assembler processing the incoming data that this cancellation request targets.
114
     */
115
    onCancelStream(contentStreamAssembler: PayloadAssembler): void {
116
        this.sendOperations.sendCancelStream(contentStreamAssembler.id).catch();
2✔
117
    }
118
}
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

© 2025 Coveralls, Inc