0.0.20 • Published 3 years ago

@withkoji/dispatch v0.0.20

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

Koji Dispatch (deprecated)

npm (scoped)

Create real-time functionality in your Koji templates.

Overview

The @withkoji/dispatch package enables you to implement real-time functionality in your Koji template. For example, chats, multi-player games, and polls.

You can use dispatch on the frontend to enable real-time updates and communication between connected clients. You can also use it transactionally on the backend to send secure messages to specific clients that have been identified with a short-lived token.

DEPRECATED This package is deprecated and is included only for backwards compatibility. For new templates, use @withkoji/core.

Installation

Install the package in your Koji project.

npm install --save @withkoji/dispatch

NOTE: You must also install the @withkoji/vcc package.

Basic use

Import and instantiate Dispatch on the frontend.

import Dispatch from '@withkoji/dispatch';
const dispatch = new Dispatch({
  projectId: instantRemixing.get(['metadata', 'projectId']),
});

Import and instantiate Dispatch on the backend.

import Dispatch from '@withkoji/dispatch';
const dispatch = new Dispatch({
  projectId: res.locals.KOJI_PROJECT_ID || process.env.KOJI_PROJECT_ID,
  options: {
    projectToken: res.locals.KOJI_PROJECT_TOKEN || process.env.KOJI_PROJECT_TOKEN,
  },
});

Use the connect function to join an open shard.

dispatch.connect();

Emit and respond to events for multi-user functionality.

dispatch.emitEvent('myEvent', myDataPayload);
dispatch.on('myEvent', myHandlerFunction);

Related resources

Contributions and questions

See the contributions page on the developer site for info on how to make contributions to Koji repositories and developer documentation.

For any questions, reach out to the developer community or the @Koji Team on our Discord server.

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.12

4 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago