1.0.31 • Published 4 years ago

tingz-sdk v1.0.31

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

👨‍💻 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
1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.23

4 years ago

1.0.19

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago