npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@enklu/node-sdk

v2020.11.0

Published

Resources for interacting with the Enklu Cloud Web APIs

Readme

Enklu Multiplayer SDK for Node.Js

Every experience developed on Enklu Cloud is backed by a powerful mutliplayer service, Mycelium. The goal of this SDK is to provide external applications and devices with session-based access to experiences via Mycelium. With this SDK, you can send and receive messages to Enklu Cloud from your own servers, IoT devices, custom applications, and whatever else you can imagine.

Installing

npm install @enklu/node-sdk

Getting Started

An Enklu Cloud account is required to use this SDK. Once you have an account set up, you can generate a token for the authoring API.

curl -X POST 'https://cloud.enklu.com:10001/v1/email/signin' \
     -H 'Content-Type: application/json' \
     -d '{"email":"[email protected]","password":"12345"}'

The token value received in a successful response can then be used to generate a multiplayer token. Each token is associated with a specific experience, so an experience Id is required as well. You can find the app id for an experience on the "My Experiences" modal or in the Inspector panel when the root element of an experience is selected in the Enklu Cloud web editor.

curl -X POST 'https://cloud.enklu.com:10001/v1/app/${your-app-id}/token' \
     -H 'Authorization: Bearer ${your-jwt-token}' \
     -H 'Content-Type: application/json' \
     -d '{}'

A successful respnse will contain a Json Web Token that can be used in the SDK. Now you can start sending messages.

const {Mycelium} = require('@enklu/node-sdk');

const JWT = process.env.JWT;
const mycelium = new Mycelium();

let isLoggedIn = false;

mycelium.on('message', (msg) => {
  console.log(`received ${msg.event} event`);
  if (msg.event === 'LoginResponse') {
    isLoggedIn = true;
  }

  if (isLoggedIn) {
    mycelium.broadcast('ping', 'hello from the sdk');
  }
});

mycelium.on('connect', () => {
  console.log('connected to mycelium!');
  mycelium.login(JWT);
});

mycelium.connect();

The example above opens a connection to Mycelium, logs in using a previously generated multiplayer token (see Getting Started), and broadcasts the message 'hello from the sdk' to all other clients connected to the multiplayer for the current experience. A more detailed example can be found in src/example.js.

API Reference

connect([ip, port])

Opens a TCP connection with the multiplayer server.

Parameters

  • ip (string): [Optional] The address of a Mycelium instance.
  • port (string): [Optional] The port of a Mycelium instance.

login(jwt)

Log in to the multiplayer server with a token provided by the authoring api. Note that this is a different token than is used to communicate with the authoring API.

Parameters

  • jwt (string): An authentication token.

on(event, handler)

Register a function for an event.

Parameters

  • event (string): The message type.
  • handler (function) The handler that should receive events.

Events

  • 'message': Invoked when a Mycelium message is received.
  • 'connect': Invoked when a TCP connection is established.
  • 'error': Invoked when an error is encountered.
  • 'close': Invoked when the TCP connection is closed.
  • 'drain': Invoked when all data has been read from the socket.
  • (message-type): Invoked for specific message schema type, such as 'scenediffevent'. For a complete list of message types, look at src/schema/schemaMap.js

off(event, handler)

Remove a registration for an event.

Parameters

  • event (string): The message type.
  • handler (function) The handler that should no longer receive events.

broadcast(type, [payload, memberId])

Sends a notification to one member or all members of the room.

Parameters

  • type (string): User-defined message id.
  • payload (any): [Optional] The data to send. If an object is passed, it will be encoded as a string. All recipients will receive it encoded as a string as well.
  • member (string): [Optional] An optional id of a specific recipient. If not included, all members besides the sender will receive the message.

ping([pingId])

Send a heartbeat to the server to keep the room alive.

Parameters

  • pingId (integer): [Optional] An optional ping id. If not provided, one is generated.

pingBack(pingId)

Repond to a ping request. This is most commonly used to respond immedately to a PingRequest event from the server.

Parameters

  • pingId (integer): The id of a previous PingEvent.

sendMessage(msg)

General purpose for sending messages to the multiplayer server. For a complete list of messages types, see the JSON schema files in src/schema.

Parameters

  • msg (object): The message to send.
  • msg.id (integer): The message type id. Optional if msg.event is defined.
  • msg.event (string): The message type name. Optional if msg.id is defined.
  • msg.payload (object): The message data, which varies by message type.

close()

Closes and destroys the connection to the multiplayer server.