mirror of
https://github.com/bitwarden/browser
synced 2025-12-31 23:53:37 +00:00
[PM-7646][PM-5506] Rust IPC changes: Episode 2 (#11122)
* Revert "[PM-7646][PM-5506] Revert IPC changes (#10946)"
This reverts commit ed4d481e4d.
* Ensure tmp dir gets created on MacOS
* Remove client reconnections
* Improve client error handling and process exiting
This commit is contained in:
30
apps/desktop/desktop_native/napi/index.d.ts
vendored
30
apps/desktop/desktop_native/napi/index.d.ts
vendored
@@ -51,3 +51,33 @@ export namespace powermonitors {
|
||||
export function onLock(callback: (err: Error | null, ) => any): Promise<void>
|
||||
export function isLockMonitorAvailable(): Promise<boolean>
|
||||
}
|
||||
export namespace ipc {
|
||||
export interface IpcMessage {
|
||||
clientId: number
|
||||
kind: IpcMessageType
|
||||
message?: string
|
||||
}
|
||||
export const enum IpcMessageType {
|
||||
Connected = 0,
|
||||
Disconnected = 1,
|
||||
Message = 2
|
||||
}
|
||||
export class IpcServer {
|
||||
/**
|
||||
* Create and start the IPC server without blocking.
|
||||
*
|
||||
* @param name The endpoint name to listen on. This name uniquely identifies the IPC connection and must be the same for both the server and client.
|
||||
* @param callback This function will be called whenever a message is received from a client.
|
||||
*/
|
||||
static listen(name: string, callback: (error: null | Error, message: IpcMessage) => void): Promise<IpcServer>
|
||||
/** Stop the IPC server. */
|
||||
stop(): void
|
||||
/**
|
||||
* Send a message over the IPC server to all the connected clients
|
||||
*
|
||||
* @return The number of clients that the message was sent to. Note that the number of messages
|
||||
* actually received may be less, as some clients could disconnect before receiving the message.
|
||||
*/
|
||||
send(message: string): number
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user