Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/dataChannel/common/dataChannel.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
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 { Event } from '../../../base/common/event.js';
7
import { createDecorator } from '../../instantiation/common/instantiation.js';
8
9
export const IDataChannelService = createDecorator<IDataChannelService>('dataChannelService');
10
11
export interface IDataChannelService {
12
readonly _serviceBrand: undefined;
13
14
readonly onDidSendData: Event<IDataChannelEvent>;
15
16
getDataChannel<T>(channelId: string): CoreDataChannel<T>;
17
}
18
19
export interface CoreDataChannel<T = unknown> {
20
sendData(data: T): void;
21
}
22
23
export interface IDataChannelEvent<T = unknown> {
24
channelId: string;
25
data: T;
26
}
27
28
export class NullDataChannelService implements IDataChannelService {
29
_serviceBrand: undefined;
30
get onDidSendData(): Event<IDataChannelEvent<unknown>> {
31
return Event.None;
32
}
33
getDataChannel<T>(_channelId: string): CoreDataChannel<T> {
34
return {
35
sendData: () => { },
36
};
37
}
38
}
39
40