mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 03:28:33 -05:00
Merge from vscode 31e03b8ffbb218a87e3941f2b63a249f061fe0e4 (#4986)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
|
||||
export interface IExtHostReadyMessage {
|
||||
type: 'VSCODE_EXTHOST_IPC_READY';
|
||||
}
|
||||
|
||||
export interface IExtHostSocketMessage {
|
||||
type: 'VSCODE_EXTHOST_IPC_SOCKET';
|
||||
initialDataChunk: string;
|
||||
}
|
||||
|
||||
export const enum MessageType {
|
||||
Initialized,
|
||||
Ready,
|
||||
Terminate
|
||||
}
|
||||
|
||||
export function createMessageOfType(type: MessageType): VSBuffer {
|
||||
const result = VSBuffer.alloc(1);
|
||||
|
||||
switch (type) {
|
||||
case MessageType.Initialized: result.writeUint8(1, 0); break;
|
||||
case MessageType.Ready: result.writeUint8(2, 0); break;
|
||||
case MessageType.Terminate: result.writeUint8(3, 0); break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isMessageOfType(message: VSBuffer, type: MessageType): boolean {
|
||||
if (message.byteLength !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (message.readUint8(0)) {
|
||||
case 1: return type === MessageType.Initialized;
|
||||
case 2: return type === MessageType.Ready;
|
||||
case 3: return type === MessageType.Terminate;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user