Path: blob/main/src/vs/platform/dataChannel/common/dataChannel.ts
3294 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../base/common/event.js';6import { createDecorator } from '../../instantiation/common/instantiation.js';78export const IDataChannelService = createDecorator<IDataChannelService>('dataChannelService');910export interface IDataChannelService {11readonly _serviceBrand: undefined;1213readonly onDidSendData: Event<IDataChannelEvent>;1415getDataChannel<T>(channelId: string): CoreDataChannel<T>;16}1718export interface CoreDataChannel<T = unknown> {19sendData(data: T): void;20}2122export interface IDataChannelEvent<T = unknown> {23channelId: string;24data: T;25}2627export class NullDataChannelService implements IDataChannelService {28_serviceBrand: undefined;29get onDidSendData(): Event<IDataChannelEvent<unknown>> {30return Event.None;31}32getDataChannel<T>(_channelId: string): CoreDataChannel<T> {33return {34sendData: () => { },35};36}37}383940