agora-chat-sdk

Agora chat websdk

Usage no npm install needed!

<script type="module">
  import agoraChatSdk from 'https://cdn.skypack.dev/agora-chat-sdk';
</script>

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:

  1. Install
npm install easemob-websdk --save
  1. Import websdk
import websdk from 'easemob-websdk'
  1. Initialize the SDK
const WebIM = {}
const conn = WebIM.conn = new websdk.connection({
    appKey: 'your app key',
    isHttpDNS: true
})
  1. Login chat server
const options = { 
  user: 'username',
  pwd: 'password'
};
conn.open(options);
  1. 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);