2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { Emitter, Event } from '../../../base/common/event.js';
7
>
import { Disposable } from '../../../base/common/lifecycle.js';
8
>
import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
9
>
import { JSON_RPC_PARSE_ERROR, type AhpServerNotification, type JsonRpcNotification, type JsonRpcParseErrorResponse, type JsonRpcRequest, type JsonRpcResponse, type ProtocolMessage } from '../common/state/sessionProtocol.js';
10
>
import type { IProtocolServer, IProtocolTransport } from '../common/state/sessionTransport.js';
11
>
12
>
/**
13
>
* Adapts MessagePort IPC clients to Agent Host Protocol transports.
14
>
*
15
>
* Consumers must call {@link closeClient} when a UtilityProcessServer client
16
>
* connection disappears.
17
>
*/
18
>
export class MessagePortProtocolServer<TContext> extends Disposable implements IProtocolServer, IServerChannel<TContext> {
19
20
private readonly _onConnection = this._register(new Emitter<IProtocolTransport>());