teamtalk-web-client
TypeScript icon, indicating that this package has built-in type declarations

1.3.21 • Public • Published

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

  • typescript interface: Message/userInfo/MsgType/...
  • session list user online status
  • retry when message sent failed
  • [] kick off by server
  • support send image
  • support audio message(Send/Receive/Play)
  • support remove session
  • add contact list (friend)
  • get user info from api
  • support custom message type = 3 (good card)
  • Component-based examples
  • get login user info
  • Promise-based WebSocket Client
  • loading more messages
  • login and get the socket url
  • open new chat by user ID
  • [] support send goods card
  • [] local message store(indexDB)
  • mark message as read

Readme

Keywords

none

Package Sidebar

Install

npm i teamtalk-web-client

Weekly Downloads

1

Version

1.3.21

License

WTFPL

Unpacked Size

218 kB

Total Files

84

Last publish

Collaborators

  • fireyy