microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
c764d5e2bcaf8e8de611998b26b56ffef0f1d583

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/extensionMessaging.ts

40lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import {HostPlatform} from "./hostPlatform";
5import {Crypto} from "./node/crypto";
6
7/**
8 * Defines the messages sent to the extension.
9 * Add new messages to this enum.
10 */
11export enum ExtensionMessage {
12 START_PACKAGER,
13 STOP_PACKAGER,
14 PREWARM_BUNDLE_CACHE,
15 START_MONITORING_LOGCAT,
16 STOP_MONITORING_LOGCAT
17}
18
19export interface MessageWithArguments {
20 message: ExtensionMessage;
21 args: any[];
22}
23
24export let ErrorMarker = "vscodereactnative-error-marker";
25
26export class MessagingChannel {
27 constructor(private projectRootPath: string) {
28 // Nothing needed here
29 }
30
31 public getPath(): string {
32 /* We need to use a different value for each VS Code window so the pipe names won't clash.
33 We create the pipe path hashing the user id + project root path so both client and server
34 will generate the same path, yet it's unique for each vs code instance */
35 const userID = HostPlatform.getUserID();
36 const uniqueSeed = `${userID}:${this.projectRootPath}`;
37 const hash = new Crypto().hash(uniqueSeed);
38 return HostPlatform.getPipePath(`vscode-reactnative-${hash}`);
39 }
40}