eyeson-node
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

eyeson-node JavaScript API Library

A NodeJS library for the Eyeson API. It provides a client that allows to easily build applications that can start and manage eyeson video conferences.

A full API documentation including all features is available at docs.eyeson.com/docs/rest/intro/.

Installation

Add eyeson-node to your JavaScript project using npm or yarn.

$ npm install --save eyeson-node
# or
$ yarn add eyeson-node

Usage

Get an API-KEY from developers.eyeson.team.

import Eyeson from 'eyeson-node'
const eyeson = new Eyeson({ apiKey: '< api-key >' }) // configure to use your api key

To create a new meeting join a room. Note: The string typed identifier id represents which room to join. Users joining the same room-id will be connected. If you do not specify an identifier, there will be a new meeting created with every join request.

Read more about creating a new meeting https://docs.eyeson.com/docs/rest/references/room

const user = await eyeson.join(username, roomIdentifier, options)
// Ensure the user (and meeting) is ready
await user.waitReady()

// Send a message into meeting chat...
await user.chat("/me sends a message")

// Update Layers and Layout
await user.setLayer({ url })
await user.clearLayer(layerIndex)

// Start a playback
await user.startPlayback({ url })

// Set a layout
await user.setLayout({ layout: "auto", show_names: false })

// Start and Stop Recoding
await user.startRecording()
await user.stopRecording()

// Start and Stop Broadcast
await user.startBroadcast(streamUrl)
await user.stopBroadcast()

// Stop a meeting for all participants
await user.stopMeeting()

Discover new functions:

// Snapshot info and delete
const snapshotInfo = await eyeson.getSnapshot(snapshotId)
const snapshots = await eyeson.getRoomSnapshots(roomId, page, startedAt)
await eyeson.deleteSnapshot(snapshotId)

// Recording info and delete
const recordingInfo = await eyeson.getRecording(recordingId)
const recordings = await eyeson.getRoomRecordings(roomId, page, startedAt)
await eyeson.deleteRecording(recordingId)

// Get user object after join
const user = await eyeson.getUser(accessKey)

// Register a guest user
const guest = await eyeson.registerGuest(username, guestToken, options)

// Start and stop a playback
await user.startPlayback({ play_id, url })
await user.stopPlayback(play_id)

// Send a custom message
await user.sendCustomMessage(message)

// Create a snapshot
await user.snapshot()

// Lock meeting to prevent new participants
await user.lockMeeting()

Layer updates

You can send local images:

import Eyeson from 'eyeson-node'
import fsPromise from 'node:fs/promise'

const eyeson = new Eyeson({ apiKey: '< api-key >' }) // configure to use your api key
const user = await eyeson.join(username)
const imageBuffer = await fsPromise.readFile('./overlay.png')
await user.sendLayer(imageBuffer, 1, 'png')
// or as jpg:
const imageBuffer = await fsPromise.readFile('./overlay.jpg')
await user.sendLayer(imageBuffer, 1, 'jpg')

Using the new eyeson-node-layer plugin you can create and send layers with ease.

import Eyeson from 'eyeson-node'
import EyesonLayer from 'eyeson-node-layer'

const user = eyeson.join('< username >', '< room id >', { options: { widescreen: true } })
const overlay = new EyesonLayer({ widescreen: true })
const timeEntry = overlay.addTextBox(new Date().toLocaleTimeString(), font, fontColor, x, y, origin, padding, maxWidth, radius, backgroundColor)
await user.sendLayer(overlay)
setTimeout(async () => {
    timeEntry.text = new Date().toLocaleTimeString()
    await user.sendLayer(overlay)
}, 60 * 1000) // update time every minute

Meeting observer

Since version 1.1.0, eyeson-node has the meeting observer included. You can read more about it here: https://docs.eyeson.com/docs/category/meeting-observer

import Eyeson from 'eyeson-node'
const eyeson = new Eyeson({ apiKey: '< api-key >' }) // configure to use your api key

const meeting = await eyeson.join(username)

const connection = eyeson.observer.connect(meeting.roomId)
connection.on('event', event => {
    if (event.type === 'room_update') {
        console.log(event.content)
    }
    else if (event.type === 'chat') {
        console.log(event.content)
    }
    else if (event.type === 'participant_update') {
        console.log(event.participant)
    }
    // and many more
})
// ...later...
connection.close() // closes automatically on shutdown

Development

$ npm install
$ npm run test -- --watch
$ npm run build

Releases

  • 1.2.0 New functions; Layer updates
  • 1.1.0 Import/require; Type declaration; Meeting observer
  • 1.0.0 Initial release

Readme

Keywords

none

Package Sidebar

Install

npm i eyeson-node

Weekly Downloads

7

Version

1.2.0

License

MIT

Unpacked Size

2.93 MB

Total Files

21

Last publish

Collaborators

  • eyeson