👨💻 Tingz SDK
How to use
yarn add tingz-sdk
Import the SDK and initialize.
import Tingz from 'tingz-sdk'
const tingz = new Tings(APP_API_KEY)
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)
})
Other Methods
tingz.getMeetingUserList((userList) => {
console.log(userList)
})
tingz.getMeetingUserHost((userHost) => {
console.log(userHost)
})
tingz.changeMeetingUserHost(userId, (wasUpdated) => {
console.log(wasUpdated)
})
Events
Events can be listened to through the on()
function.
ready | SDK initialization complete |
message | Incoming message |
userConnected | User connected to Tingz meeting room |
userDisconnected | User disconnected from Tingz meeting room |
meetingHostUpdated | Tingz meeting room host user was changed |
tingz.on('ready', () => console.log('App is ready!'))
tingz.on('message', (data) => console.log('Message', data))
tingz.on('userConnected', (user) => console.log('User connected', user))
tingz.on('userDisconnected', (user) => console.log('User disconnected', user))
tingz.on('meetingHostUpdated', (hostUser) => console.log('Meeting host user', hostUser))
User
A user object is exposed with the following properties:
id | String | Unique ID of the current user |
username | String | Username of the current user |
isHost | Boolean | true is current user is the meeting host |