0.1.14 • Published 5 years ago

jcom v0.1.14

Weekly downloads
66
License
-
Repository
gitlab
Last release
5 years ago

jcom

A super awesome TCP/IPC module that supports JSON messages.

Work In Progress!

This module needs some refinements before it can be used in production.

Quick Start

On the server:

const { JcomServer } = require(`jcom`);

const server = new JcomServer(`unique-server-identity`, `tcp`);

server.onMessage(`awesome-message`, async (client, message) => {
	/* await doSomethingCool(message); */
});

await server.listen(`127.0.0.1:5728`);

await server.broadcast([ `dingos`, `ducks` ], `some-message-type`, {
	hello: `world`,
});

const allClients = server.getClients();

await server.send(allClients, `some-message-type`, {
	hello: `world`,
});

On the client:

const { JcomClient } = require(`jcom`);

const client = new JcomClient(`some-unique-client-id-string`, `tcp`, {
	groups: [ `ducks`, `dogs`, `dingos` ],
});

client.onMessage(`some-message-type`, async message => {
	/* await doSomethingEvenCooler(message); */
});

await client.connect(`127.0.0.1:5728`);

await client.send(`awesome-message`, {
	some: `data`,
	number: 1
});

await client.broadcast([ `dogs` ], `awesome-message`, {
	some: `data`,
	number: 1
});

Reserved Message Types

The following message types are reserved and should not be used by your code:

  • jcom/server-ready - Server emits this event to newly connected clients when its ready to accept further messages.
  • jcom/identification - Client emits this event after connecting to a server to identify itself.
  • jcom/client-broadcast - Client emits this event to a server when it wants to broadcast to other clients.
0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago