packages/electron-server-ipc/README.md
IPC (Inter-Process Communication) module between LobeHub's Electron application and server, providing reliable cross-process communication capabilities.
@lobechat/electron-server-ipc is a core component of LobeHub's desktop application, responsible for handling communication between the Electron main process and Next.js server. It provides a simple yet robust API for passing data and executing remote method calls across different processes.
Responsible for listening to client requests and responding, typically runs in Electron's main process:
import { ElectronIPCEventHandler, ElectronIPCServer } from '@lobechat/electron-server-ipc';
// Define handler functions
const eventHandler: ElectronIPCEventHandler = {
getDatabasePath: async () => {
return '/path/to/database';
},
// Other handler functions...
};
// Create and start server
const server = new ElectronIPCServer(eventHandler);
server.start();
Responsible for connecting to the server and sending requests, typically used in the server (such as Next.js service):
import { ElectronIPCMethods, ElectronIpcClient } from '@lobechat/electron-server-ipc';
// Create client
const client = new ElectronIpcClient();
// Send request
const dbPath = await client.sendRequest(ElectronIPCMethods.getDatabasePath);
IPC server implementations need to handle various communication scenarios and edge cases. We welcome community contributions to enhance reliability and functionality. You can participate in improvements through:
This is an internal module of LobeHub ("private": true), designed specifically for LobeHub desktop applications and not published as a standalone package.