UNPKG

sussudio

Version:

An unofficial VS Code Internal API

29 lines (28 loc) 1 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ /** * The Electron `Protocol` leverages Electron style IPC communication (`ipcRenderer`, `ipcMain`) * for the implementation of the `IMessagePassingProtocol`. That style of API requires a channel * name for sending data. */ export class Protocol { sender; onMessage; constructor(sender, onMessage) { this.sender = sender; this.onMessage = onMessage; } send(message) { try { this.sender.send('vscode:message', message.buffer); } catch (e) { // systems are going down } } disconnect() { this.sender.send('vscode:disconnect', null); } }