@todesktop/plugin-comm-server
TypeScript icon, indicating that this package has built-in type declarations

0.55.0 • Public • Published

ToDesktop Communication Server

Communicate between the web browser and your desktop app.

Installation

Install @todesktop/client-comm-server in your client-side application using

npm install @todesktop/client-comm-server

Installation of the plugin package is also necessary. Using ToDesktop Builder, navigate to Plugins. Click on the Explore button for "Communication Server" and install the package.

Usage

checkIfCommServerRunning

Checks to see if the communication server is currently running. This should be executed from the context of the web app attempting communication with a local desktop app.

import { checkIfCommServerRunning } from "@todesktop/client-comm-server";

const ports = [20001, 39214];
checkIfCommServerRunning(ports).then(async (isRunning) => {
  console.log(isRunning); // true
});

broadcast

Broadcasts a message to the running desktop app.

import { broadcast } from "@todesktop/client-comm-server";

const ports = [20001, 39214];

const res = await broadcast(ports, { foo: "bar" });

console.log(res);

handleBroadcast

Listens to messages that have been forwarded from the communication server.

import { handleBroadcast } from "@todesktop/client-comm-server";

const unsubscribe = handleBroadcast((data) => {
  console.log(data);
  return "acknowledged";
});

// ...later
unsubscribe();

Readme

Keywords

none

Package Sidebar

Install

npm i @todesktop/plugin-comm-server

Weekly Downloads

1

Version

0.55.0

License

ISC

Unpacked Size

21.3 kB

Total Files

12

Last publish

Collaborators

  • isaacaderogba
  • megahertz
  • davej