Skip to content

Cumcord/cummunicate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cummunicate

The easy as piss way to talk to Cumcord from your website.

For example:

// Find the port numbers of all available Cumcord instances.
const ports = (await cummunicate("get_info")).map(p => p[0]);

Installation

Bundler

npm i @cumjar/cummunicate

import cummunicate from "@cumjar/cummunicate";

cummunicate()

Browser (ES Modules)

<script type="module">
	import cummunicate from "https://cdn.esm.sh/@cumjar/cummunicate";

	cummunicate()
</script>

Browser (Traditional)

<script src="https://cdn.esm.sh/@cumjar/cummunicate/dist/browser.js"/>
<script>
	cummunicate()
</script>

Usage

The cummunicate function takes one or two args:

  • action: string - The action to invoke on all available clients
  • payload?: object - Any data to attach to the WS initiator message

It returns a promise of an array. Each array elem is a tuple of the following:

  • [0]: number - The port of the client this reply is from
  • [1]: WsReply - The reply obtained from the client

Cummunicate will try to talk to any Cumcord instance that will connect.