Enklu Documentation

Enklu Documentation

  • What's New
  • Guides
  • API Reference
  • FAQ
  • Contact

›Scripting

Guides Overview

  • Guides Overview

Web Editor Basics

  • Web Editor Interface
  • Minimum Requirements
  • Managing Your Experiences
  • Sharing Experiences with Others
  • Keyboard Shortcuts
  • Placing an Asset in the Scene
  • Lights
  • Scene Settings
  • Post-Processing
  • Web Play Mode

HoloLens

  • Hololens 2 Basics & Setup
  • Hololens (1st gen) Basics & Setup
  • Voice Commands
  • Live Preview
  • Video Recording
  • Remote Debugging
  • Occlusion

Chapters Series

  • Chapter 1: Intro to Enklu Cloud
  • Chapter 2: Thinking in 3D
  • Chapter 3: Adding Lights & Effects
  • Chapter 4: Adding Interactions

Assets

  • Import Your Own Assets
  • Public Assets
  • Exporting Unity Prefabs
  • Adding Animations from Unity
  • Scene Complexity Recommendations
  • Audio
  • PBR Pipeline

Spaces

  • Creating a Space
  • Updating a Space
  • Adding Anchors
  • Downloading the Scan

Scripting

  • Public Scripts
  • Introduction to Scripting
  • Vine Script Basics
  • Behavior Script Basics
  • Controlling Animations
  • Node SDK

Enklu Embedded

  • Installing Enklu Embedded
  • Embedding an Experience in Your Unity Scene
  • Syncing Assets From Unity

Node SDK

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.

Should I use this SDK?

Enklu Cloud's behavior scripting can be used to create multiplayer experiences, as documented here.

This SDK is designed for users who have specific use cases that requires multiplayer code to be running external from user devices.

Installing

In the future a NPM module will be available. Currently, it can be cloned directly from GitHub.

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":"roland@druidia.com","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();

API Reference

A more comprehension API reference is available on GitHub.

← Controlling AnimationsInstalling Enklu Embedded →
  • Should I use this SDK?
  • Installing
  • Getting Started
  • API Reference
Enklu Documentation
Docs
Release NotesGuidesAPI ReferenceFAQ
Social
FacebookInstagramLinkedInTwitter
Community
GitHubSlackUser Feedback
Copyright © 2021 Enklu, Inc.