microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
18d8ad2abfdce9bcdb96cc3fe6fb491da873c8f6

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/extensionMessaging.ts

41lines · 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 SEND_TELEMETRY
18}
19
20export interface MessageWithArguments {
21 message: ExtensionMessage;
22 args: any[];
23}
24
25export let ErrorMarker = "vscodereactnative-error-marker";
26
27export class MessagingChannel {
28 constructor(private projectRootPath: string) {
29 // Nothing needed here
30 }
31
32 public getPath(): string {
33 /* We need to use a different value for each VS Code window so the pipe names won't clash.
34 We create the pipe path hashing the user id + project root path so both client and server
35 will generate the same path, yet it's unique for each vs code instance */
36 const userID = HostPlatform.getUserID();
37 const uniqueSeed = `${userID}:${this.projectRootPath}`;
38 const hash = new Crypto().hash(uniqueSeed);
39 return HostPlatform.getPipePath(`vscode-reactnative-${hash}`);
40 }
41}
42