1.0.8 • Published 6 months ago

twine-server-library v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Twine Server Library

This library enables users to publish messages to their Twine Realtime service.

Installation

Copy this code into your JavaScript code as an ES module package:

import TwineServerLibrary from 'https://cdn.jsdelivr.net/npm/twine-server-library@1.0/+esm';

Initialization

To configure the client, use the Twine constructor, it requires a Twine host and apiKey created at deployment:

const host = 'https://your-twine-domain.com';
const twineServerLibrary = new TwineServerLibrary(host, apiKey);

Once the constructor has been invoked, messages may be published to the twine server.

Usage

publish

The publish method takes a room (string) and a JavaScript object that serves as the messages payload. When invoked the messages will be sent to the twine server and the message published to all subscribers of the room.

twineServerLibrary.publish(room, callback); 
sendBtn.addEventListener('click', (e) => {
	e.preventDefault();
	const message = input.value;
	twineServerLibrary.publish(room, { 
		message: "Goodmoring, friend!"
	}); 
})
1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago