Constructor
new(accountId:String, persistence:Persistence)
Create a new Client to connect to a particular account
Parameters:
accountId | the account to connect to |
|---|---|
persistence | the persistence layer to use for storage |
Variables
Methods
addCallMediaListener(handler:(InitiatedSession, Bool, Bool) ‑> Void):EventHandlerToken
Event fired when a call is asking for media to send
Parameters:
handler | takes three arguments, the call Session, a boolean indicating if audio is desired, and a boolean indicating if video is desired |
|---|
Returns:
token for use with removeEventListener
addCallRetractListener(handler:(String, String) ‑> Void):EventHandlerToken
Event fired when a call is retracted or hung up
Parameters:
handler | takes two arguments, the associated Chat ID and Session ID |
|---|
Returns:
token for use with removeEventListener
addCallRingListener(handler:Session ‑> Void):EventHandlerToken
Event fired when a new call comes in
Parameters:
handler | takes one argument, the call Session |
|---|
Returns:
token for use with removeEventListener
addCallRingingListener(handler:Session ‑> Void):EventHandlerToken
Event fired when an outgoing call starts ringing
Parameters:
handler | takes two arguments, the associated Chat ID and Session ID |
|---|
Returns:
token for use with removeEventListener
addCallTrackListener(handler:(InitiatedSession, MediaStreamTrack, Array<MediaStream>) ‑> Void):EventHandlerToken
Event fired when call has a new MediaStreamTrack to play
Parameters:
handler | takes three arguments, the associated Chat ID, the new MediaStreamTrack, and an array of any associated MediaStreams |
|---|
Returns:
token for use with removeEventListener
addCallUpdateStatusListener(handler:InitiatedSession ‑> Void):EventHandlerToken
Event fired when an existing call changes status (connecting, failed, etc)
Parameters:
handler | takes one argument, the associated Session |
|---|
Returns:
token for use with removeEventListener
addChatMessageListener(handler:(ChatMessage, ChatMessageEvent) ‑> Void):EventHandlerToken
Event fired when a new ChatMessage comes in on any Chat Also fires when status of a ChatMessage changes, when a ChatMessage is edited, or when a reaction is added
Parameters:
handler | takes two arguments, the ChatMessage and ChatMessageEvent enum describing what happened |
|---|
Returns:
token for use with removeEventListener
addChatsUpdatedListener(handler:Array<Chat> ‑> Void):EventHandlerToken
Event fired when a Chat's metadata is updated, or when a new Chat is added
Parameters:
handler | takes one argument, an array of Chats that were updated |
|---|
Returns:
token for use with removeEventListener
addConnectionFailedListener(handler:() ‑> Void):EventHandlerToken
Event fired when connection fails with a fatal error and will not be retried
Parameters:
handler | takes no arguments |
|---|
Returns:
token for use with removeEventListener
addPasswordNeededListener(handler:Client ‑> Void):EventHandlerToken
Event fired when client needs a password for authentication
Parameters:
handler | takes one argument, the Client that needs a password |
|---|
Returns:
token for use with removeEventListener
addStatusOfflineListener(handler:() ‑> Void):EventHandlerToken
Event fired when client is disconnected
Parameters:
handler | takes no arguments |
|---|
Returns:
token for use with removeEventListener
addStatusOnlineListener(handler:() ‑> Void):EventHandlerToken
Event fired when client is connected and fully synchronized
Parameters:
handler | takes no arguments |
|---|
Returns:
token for use with removeEventListener
addSyncMessageListener(handler:ChatMessage ‑> Void):EventHandlerToken
Event fired when syncing a new ChatMessage that was send when offline. Normally you don't want this, but it may be useful if you want to notify on app start.
Parameters:
handler | takes one argument, the ChatMessage |
|---|
Returns:
token for use with removeEventListener
addTlsCheckListener(handler:(String, Array<String>) ‑> Bool):EventHandlerToken
Event fired when TLS checks fail, to give client the chance to override
Parameters:
handler | takes two arguments, the PEM of the cert and an array of DNS names, and must return true to accept or false to reject |
|---|
Returns:
token for use with removeEventListener
enablePush(push_service:String, endpoint:String, p256dh:BytesData, auth:BytesData, grace:Int, ?vapid_private_pkcs8:Null<BytesData>, ?claims:Array<String>):Void
Enable push notifications
Parameters:
push_service | the address of a push proxy |
|---|---|
vapid_private_pkcs8 | the private key for signing JWT of the push service |
endpoint | the final target for the push proxy to forward to |
p256dh | A P-256 uncompressed point in ANSI X9.62 format |
auth | Random 16 octed value |
grace | Grace period during which not to generate push if another app is active for same account, in seconds (negative for none) |
claims | Optional additional JWT claims as key then value |
findAvailableChats(q:String, callback:(String, Array<AvailableChat>) ‑> Bool):Void
Search for chats the user can start or join
Parameters:
q | the search query to use |
|---|---|
callback | takes two arguments, the query that was used and the array of results |
logout(completely:Bool):Void
Destroy local data for this account
Parameters:
completely | if true chats, messages, etc will be deleted as well |
|---|
prepareAttachment(source:AttachmentSource):Promise<Null<ChatAttachment>>
Turn a file into a ChatAttachment for attaching to a ChatMessage
Parameters:
source | The AttachmentSource to use |
|---|
Returns:
Promise resolving to a ChatAttachment or null
setDisplayName(displayName:String):Void
Set the current display name for this account on the server
Parameters:
display | name to set (ignored if empty or NULL) |
|---|
startChat(availableChat:AvailableChat):Chat
Start or join a chat from the search results
Returns:
the chat that was started
startOffline():Promise<Bool>
Gets the client ready to use but does not connect to the server
Returns:
Promise resolving to true once the Client is ready
subscribePush(reg:ServiceWorkerRegistration, push_service:String, vapid_key:{publicKey:CryptoKey, privateKey:CryptoKey}, ?grace:Int):Void
usePassword(password:String):Void
Sets the password to be used in response to the password needed event
Parameters:
null | password |
|---|