New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tingz-sdk

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tingz-sdk

## How to use

1.0.31
latest
npm
Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

👨‍💻 Tingz SDK

How to use

yarn add tingz-sdk

Import the SDK and initialize.

import Tingz from 'tingz-sdk'

// Controller
const tingz = new Tings(APP_API_KEY)

// Scene Player
const tingz = new Tingz(APP_API_KEY, { isServer: true })

This SDK handles user authentication and communication between a controller app and it's scene player counterpart.

Communication is acheived through the send() and receive() functions.

Send / Receive Methods

send() accepts a JSON object which is send to the receive() function in an apps other half.

tingz.send({ action: 'START', payload: { id: 123 } })

tingz.receive((data) => {
  console.log(data) // { action: 'START', payload: { id: 123 } }
})

Other Methods

tingz.getMeetingUserList((userList) => {
  console.log(userList) // [ { id, isHost, username }, {...}, {...} ]
})

tingz.getMeetingUserHost((userHost) => {
  console.log(userHost) // { id, isHost, username }
})

tingz.changeMeetingUserHost(userId, (wasUpdated) => {
  // userIds can be obtained for example from tingz.getMeetingUserList()
  // Use this method to change the host user of the Tingz meeting room.
  console.log(wasUpdated) // Boolean
})

Events

Events can be listened to through the on() function.

EventDescription
readySDK initialization complete
messageIncoming message
userConnectedUser connected to Tingz meeting room
userDisconnectedUser disconnected from Tingz meeting room
meetingHostUpdatedTingz meeting room host user was changed
// On app initialization. `ready`
tingz.on('ready', () => console.log('App is ready!'))

// On incoming message. Same as `receive()`. `message`
tingz.on('message', (data) => console.log('Message', data))

// On user has connected to Tingz meeting room event
tingz.on('userConnected', (user) => console.log('User connected', user))

// On user has disconnected from Tingz meeting room event
tingz.on('userDisconnected', (user) => console.log('User disconnected', user))

// On meeting host user has been changed inside Tingz meeting room
tingz.on('meetingHostUpdated', (hostUser) => console.log('Meeting host user', hostUser))

User

A user object is exposed with the following properties:

KeyTypeDescription
idStringUnique ID of the current user
usernameStringUsername of the current user
isHostBooleantrue is current user is the meeting host

FAQs

Package last updated on 15 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts