teamtalk-web-client
v1.3.21
Published
Simple web chat api for TeamTalk.
Downloads
7
Readme
TeamTalk Web Client
Examples & Demos
A Simple Example.
How to use
Login
// with ES6 import
import socket from 'teamtalk-web-client';
const user = {
url: 'ws://10.0.59.26:8001',
userId: 502,
userToken: 'xxxxxxxxxxx',
appId: 3,
domainId: 1000
}
socket.login(user).then(res => {
// login success
}).catch(err => [
// lgoin failed
])
socket.on('open', () => {
//
})
Send and Receive Message
// Send Message to sessionId
// localId = new Date().getTime()
socket.sendMessage(sessionId, text, localId, sessionType);
// Receive New Message
socket.on('message', (data) => {
console.log('message', data)
})
// Get Message List
let data = await socket.getMsgList(sessionId, sessionType, latestMsgId, count)
// Typing event
socket.on('remote.typing', () => {
console.log('remote.typing')
})
// Start Typing and Stop Typing
socket.emit('client.start.typing', () => {
console.log('client.start.typing')
})
socket.emit('client.stop.typing', () => {
console.log('client.stop.typing')
})
// Ping and Pong
socket.on('ping', () => {
console.log('ping')
})
socket.on('pong', () => {
console.log('pong')
})
TODO
- [x] typescript interface: Message/userInfo/MsgType/...
- [x] session list user online status
- [] (No plan) retry when message sent failed
- [] kick off by server
- [x] support send image
- [] (No plan) support audio message(Send/Receive/Play)
- [x] support remove session
- [x] add contact list (friend)
- [x] get user info from api
- [x] support custom message type = 3 (good card)
- [x] Component-based examples
- [x] get login user info
- [x] Promise-based WebSocket Client
- [x] loading more messages
- [x] login and get the socket url
- [x] open new chat by user ID
- [] support send goods card
- [] local message store(indexDB)
- [x] mark message as read