mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
fix: issues after rebase
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IpcService } from "@bitwarden/common/platform/ipc";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { OutgoingMessage } from "@bitwarden/sdk-internal";
|
||||
|
||||
/**
|
||||
* Example service that responds to "ping" messages with "pong".
|
||||
@@ -12,11 +13,10 @@ export class IpcPongService {
|
||||
/** Must be initalized after IpcService */
|
||||
async init() {
|
||||
this.ipcService.messages$.subscribe((message) => {
|
||||
if (Utils.fromBufferToUtf8(new Uint8Array(message.data)) === "ping") {
|
||||
void this.ipcService.send({
|
||||
data: Array.from(Utils.fromUtf8ToArray("pong")),
|
||||
destination: message.source,
|
||||
});
|
||||
if (Utils.fromBufferToUtf8(new Uint8Array(message.payload)) === "ping") {
|
||||
void this.ipcService.send(
|
||||
new OutgoingMessage(Utils.fromUtf8ToArray("pong"), message.source),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { filter, firstValueFrom } from "rxjs";
|
||||
|
||||
import { IpcService } from "@bitwarden/common/platform/ipc";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { OutgoingMessage } from "@bitwarden/sdk-internal";
|
||||
|
||||
/**
|
||||
* Example service that sends a "ping" message and waits for a "pong" response.
|
||||
@@ -23,16 +24,15 @@ export class IpcPingService {
|
||||
async ping() {
|
||||
const responsePromise = firstValueFrom(
|
||||
this.ipcService.messages$.pipe(
|
||||
filter((m) => Utils.fromBufferToUtf8(new Uint8Array(m.data)) === "pong"),
|
||||
filter((m) => Utils.fromBufferToUtf8(new Uint8Array(m.payload)) === "pong"),
|
||||
),
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("Sending ping...");
|
||||
await this.ipcService.send({
|
||||
data: Array.from(Utils.fromUtf8ToArray("ping")),
|
||||
destination: "BrowserBackground",
|
||||
});
|
||||
await this.ipcService.send(
|
||||
new OutgoingMessage(Utils.fromUtf8ToArray("ping"), "BrowserBackground"),
|
||||
);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("Waiting for pong...");
|
||||
const response = await responsePromise;
|
||||
|
||||
Reference in New Issue
Block a user