VoiceLayer

Create a new voicelayer object.

The following options are valid:

  • directory - location of the worker scripts
  • apiEndpoint - URL for the VoiceLayer API.
  • pingFrequency - How frequently a "ping" should be sent to the server in milliseconds. Defaults to 120000
  • pongTimeout - time in millisconds for the server to respond with pong before attempting to reconnect the WebSocket. Defaults to 6000.
  • unavailableTimeout - time in millisconds to attempt connecting before marking the connection as unavailable. Defaults to 10000.
new VoiceLayer(key: string, secret: string, options: object?)
Parameters
key (string) API Key
secret (string) API Secret
options (object?) additional configuration options
Example
var voicelayer = new VoiceLayer("mykey", "mysecret", {
  directory: "scripts/libs/voicelayersdk",
  pingFrequency: 30000,
  pongTimeout: 4000,
  unavailableTimeout: 6000
});
Instance Members
connect()
disconnect()
on(event, callback)
off(event?, callback?)
trigger(event, data)

App

*

App
Instance Members
getInfo(callback)
getUsers(callback, page?)

Auth

*

Auth
Instance Members
setToken(token)
register(params, callback)
login(email, password, callback)
logout(callback)
resetPassword(email, callback)
resendConfirmation(email, callback)

CurrentUser

*

CurrentUser
Instance Members
getChannels(callback, page?)
getRequests(callback, page?)
getInvites(callback, page?)
update(params, callback)
updateAvatar(file, callback)
deleteMeta(keys, callback)

Users

*

Users
Instance Members
get(user, callback)

Channels

*

Channels
Instance Members
create(params, callback)
createDirect(user, callback)
get(channel, callback)
getPublic(callback, page?)
getAttachments(channel, callback, page?)
getMessages(channel, callback, page?)
getRequests(channel, callback, page?)
getUsers(channel, callback, page?)
getInvitedUsers(channel, callback, page?)
leave(channelId, callback, channel)
createAttachment(channel, file, callback)
createMessage(channel, message, callback)
update(channel, params, callback)
updateImage(channel, file, callback)
updateUserPermissions(channel, user, permissions, callback)
delete(channel, callback)
recordMessage(channel, message?)
requestAccess(channel, callback)

Recorder

*

Recorder
Instance Members
isMicEnabled()
requestMicAccess(opts, callback)
stop()
isRecording()
getDuration(callback)

Messages

*

Messages
Instance Members
get(id, callback)
getMissed(since)
update(id, message, callback)
delete(id, callback)
deleteMeta(id, keys, callback)
play(id)

Player

*

Player
Instance Members
stop()
isPlaying()

Invites

*

Invites
Instance Members
accept(channel, callback)
reject(channel, callback)
create(channel, user, callback)

Requests

*

Requests
Instance Members
accept(channel, user, callback)
reject(channel, user, callback)
cancel(channel, callback)

Attachments

*

Attachments
Instance Members
getUrl(id)

__eventCallback__

Callback for VoiceLayer events

__eventCallback__(data: data?)

Type: Function

Parameters
data (data?) the event data

__arrayCallback__

Callback used for REST API calls

__arrayCallback__(error: string, results: Array<Object>, pages: Object?)

Type: Function

Parameters
error (string) the error description. Will be null if there are no errors
results (Array<Object>) The response from the server
pages (Object?) The pages object for pagination
Example
pages = {
  next: {},
  prev: {},
  first: {},
 last: {}
}
voicelayer.app.getUsers(callback, pages.next);

__resultCallback__

Callback used for REST API calls

__resultCallback__(error: string, result: Object)

Type: Function

Parameters
error (string) the error description. Will be null if there are no errors
result (Object) The response from the server

__errorCallback__

Callback with a single error parameter

__errorCallback__(error: string?)

Type: Function

Parameters
error (string?) the error description

__durationCallback__

Callback with a single error parameter

__durationCallback__(error: string, duration: number)

Type: Function

Parameters
error (string) the error description. Will be null if there are no errors
duration (number) the duration of the last message