README
Agora chat sdk Introduction
Agora chat sdk provides complete instant messaging function development capabilities, shields/encapsulate and block its internal complex details, and provides a relatively simple and concise API interface to facilitate third-party applications to quickly integrate instant messaging functions for PC/mobile Web applications
Chat SDK can be integrated in the following way:
- Install
npm install easemob-websdk --save
- Import websdk
import websdk from 'easemob-websdk'
- Initialize the SDK
const WebIM = {}
const conn = WebIM.conn = new websdk.connection({
appKey: 'your app key',
isHttpDNS: true
})
- Login chat server
const options = {
user: 'username',
pwd: 'password'
};
conn.open(options);
- Send a message
let id = conn.getUniqueId()
let msg = new WebIM.message('txt', id);
msg.set({
msg: 'message content',
to: 'username',
chatType: 'singleChat',
success: function () {
console.log('send private text Success');
},
fail: function(e){ }
});
conn.send(msg.body);