Vue 集成环信 全局封装环信WebSDK 可直接使用
2019-11-25更新
npm install --save easemob-websdk
请直接使用官方安装方式即可。
import WebIM from 'easemob-websdk'以下是最开始版本 环信不适配所写
配置文件可用下面的
使用时请仔细检查域名与host 是否是HTTP/HHTPS协议
// Step1、安装 easemob-websdk
// npm install --save easemob-websdk// Step2、安装 strophe.js underscore crypto-js
// npm install --save strophe.js underscore crypto-jsUpdate 2019-6-19 更新 使用 hx-websdk
npm install --save hx-websdkStep3、使用 新建一个webim.js
import store from '@/store'
// window.Strophe = require('strophe.js').Strophe // 务必在前面引入
// let WebIM = require('easemob-websdk')
let WebIM = require('hx-websdk') // 使用hx-websdk集成 直接使用 WebIM.config = {
/*
* XMPP server
*/
xmppURL: 'im-api.easemob.com',
/*
* Backend REST API URL
*/
apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com',
/*
* Application AppKey
*/
appkey: '你公司的环信AppKey', /*
* Whether to use wss
* @parameter {Boolean} true or false
*/
https: false,
/*
* isMultiLoginSessions
* true: A visitor can sign in to multiple webpages and receive messages at all the webpages.
* false: A visitor can sign in to only one webpage and receive messages at the webpage.
*/
isMultiLoginSessions: false,
/*
* set presence after login
*/
isAutoLogin: true,
/**
* Whether to use window.doQuery()
* @parameter {Boolean} true or false
*/
isWindowSDK: false,
/**
* isSandBox=true: xmppURL: 'im-api-sandbox.easemob.com', apiURL: '//a1-sdb.easemob.com',
* isSandBox=false: xmppURL: 'im-api.easemob.com', apiURL: '//a1.easemob.com',
* @parameter {Boolean} true or false
*/
isSandBox: false,
/**
* Whether to console.log in strophe.log()
* @parameter {Boolean} true or false
*/
isDebug: true,
/**
* will auto connect the xmpp server autoReconnectNumMax times in background when client is offline.
* won't auto connect if autoReconnectNumMax=0.
*/
autoReconnectNumMax: 2,
/**
* the interval seconds between each auto reconnectting.
* works only if autoReconnectMaxNum >= 2.
*/
autoReconnectInterval: 2,
/**
* webrtc supports WebKit and https only
*/
isWebRTC: (/Firefox/.test(navigator.userAgent) || /WebKit/.test(navigator.userAgent)) && /^https:$/.test(window.location.protocol),
/**
* after login, send empty message to xmpp server like heartBeat every 45s, to keep the ws connection alive.
*/
heartBeatWait: 4500,
/**
* while http access,use ip directly,instead of ServerName,avoiding DNS problem.
*/
isHttpDNS: false, /**
* Will show the status of messages in single chat
* msgStatus: true show
* msgStatus: true hide
*/
msgStatus: true, /**
* When a message arrived, the receiver send an ack message to the
* sender, in order to tell the sender the message has delivered.
* See call back function onReceivedMessage
*/
delivery: true, /**
* When a message read, the receiver send an ack message to the
* sender, in order to tell the sender the message has been read.
* See call back function onReadMessage
*/
read: false, /**
* Will encrypt text message and emoji message
* {type:'none'} no encrypt
* {type:'base64'} encrypt with base64
* {type:'aes',mode: 'ebc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(ebc)
* {type:'aes',mode: 'cbc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(cbc)
*/
encrypt: {
type: 'none'
}
}
WebIM.Emoji = {
path: 'images/faces/',
map: {
'[):]': 'ee_1.png',
'[:D]': 'ee_2.png',
'[;)]': 'ee_3.png',
'[:-o]': 'ee_4.png',
'[:p]': 'ee_5.png',
'[(H)]': 'ee_6.png',
'[:@]': 'ee_7.png',
'[:s]': 'ee_8.png',
'[:$]': 'ee_9.png',
'[:(]': 'ee_10.png',
'[:\'(]': 'ee_11.png',
'[:|]': 'ee_12.png',
'[(a)]': 'ee_13.png',
'[8o|]': 'ee_14.png',
'[|]': 'ee_15.png',
'[+o(]': 'ee_16.png',
'[<o)]': 'ee_17.png',
'[|-)]': 'ee_18.png',
'[*-)]': 'ee_19.png',
'[:-#]': 'ee_20.png',
'[:-*]': 'ee_21.png',
'[^o)]': 'ee_22.png',
'[8-)]': 'ee_23.png',
'[(|)]': 'ee_24.png',
'[(u)]': 'ee_25.png',
'[(S)]': 'ee_26.png',
'[(*)]': 'ee_27.png',
'[(#)]': 'ee_28.png',
'[(R)]': 'ee_29.png',
'[({)]': 'ee_30.png',
'[(})]': 'ee_31.png',
'[(k)]': 'ee_32.png',
'[(F)]': 'ee_33.png',
'[(W)]': 'ee_34.png',
'[(D)]': 'ee_35.png'
}
}
WebIM.NewEmoji = {
map: ['Vue 集成环信 全局封装环信WebSDK 可直接使用的更多相关文章
- vue集成环信IM
vue 集成环信im 简单demo 环信AppKey:1106190415055331#test 测试账号: test1 123456 test2 123456 test3 123456 默 ...
- 李洪强iOS开发之-环信02.2_环信官网下载环信 SDK
李洪强iOS开发之-环信02.2_环信官网下载环信 SDK 移动客服即时通讯云 iOS SDK 当前版本:V3.1.4 2016-07-08 [ 版本历史 ] | 开发指南 | 知识库 | Demo源 ...
- 李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档
李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档 SDK 2.x 至 3.0 升级指南 环信 SDK 3.0 升级文档 3.0 中的核心类为 EMClient 类,通过 EMCl ...
- Android 环信(Android)设置头像和昵称的方法
最近,经常有朋友问到,如何集成环信头像,怎么才能快速显示头像,因时间紧急,很多朋友都没有时间慢慢的研究代码,这里大家稍微花10分钟看一下文章,看完后再花5分钟改一下代码,即可达到你们所要的效果. 当然 ...
- 环信集成 2---基于环信Demo3.0,实现单聊功能
这几天在做环信,所以把环信相关的东西拿过来,做个系统点的东西 注意: 这里Demo集成的是带有实时语音功能的(libEaseMobClientSDK.a). 环信库是直接拖拽EaseMobSDK文件夹 ...
- 李洪强iOS开发本人集成环信的经验总结_01环信SDK的导入
李洪强iOS开发本人集成环信的经验总结_01环信SDK的导入 01 - 直接在项目中导入SDK和一些静态库 这个时候,没有错误的编译没有错误的话,就说明SDK已经配置成功 还有一种方法是用cocoap ...
- Apple Watch 集成环信SDK
本文简单的讲述下怎样用Apple Watch Kit集成环信SDK. 升级xcode到version 6.2,和 IOS SDK8.2 下载环信SDK从官网 打开XCode->new proje ...
- iOS:集成环信EaseMobSDK单聊功能
当然在集成环信之前需要一些准备操作: 1.首先注册环信开发者账号,直接进入环信官网注册即可:http://www.easemob.com 2.按照文档一步一步将需要的文件全部拖入工程中:http:// ...
- 李洪强iOS开发本人集成环信的经验总结_03_注册
李洪强iOS开发本人集成环信的经验总结_03_注册 环信一共提供了三种注册的方法: 01 同步注册: 02 异步注册: 03 - 使用代理回调进行注册,但是3.0没有了,3.0之前有 调用注册 ...
随机推荐
- 108-PHP类成员protected和private成员属性不能被查看数值
<?php class mao{ //定义猫类 public $age; //定义多个成员属性 protected $weight; private $color; } $mao1=new ma ...
- mysql多表连接查询
新建两张表: 表1:student 截图如下: 表2:course 截图如下: (此时这样建表只是为了演示连接SQL语句,当然实际开发中我们不会这样建表,实际开发中这两个表会有自己不同的主键.) ...
- 一万五千字的Dissertation你真的会写了吗?
在英国留学的同学们想要顺利毕业,就必须要过Dissertation这一关.而一篇Dissertation字数可能多大一万五千字,其写作难度之大让很多留学生疯狂吐槽.那么这么多字的Dissertatio ...
- 干货分享:常见的留学生Essay写作逻辑结构
任何一种类型的Essay写作都应遵循一种逻辑结构,Long Essay可能在不同部分依据情况使用不同的逻辑结构.本文将为大家分享六种常见留学生Essay写作逻辑结构,为方便阅读本文采用中英文对照方式. ...
- Java中的super关键字和this关键字作用介绍
一.super关键字的作用 1.子类在构造方法中显示调用父类构造方法 super可以在子类的构造方法中显示调用父类的构造方法:并且这行代码必须出现在子类构造方法的第一行.原因:因为父类构造方法没有执行 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-lock
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- P 1032 挖掘机技术哪家强
转跳点:
- 中国移动携手华为百度展示5G应用,实现8K视频传输
在今日举行的 2019 年百度云智峰会上,中国移动携手华为和百度,首次展示基于 SA 架构的 5G Vertical LAN (行业局域网)技术,承载 8K 实时会议系统,助力企业云办公.该技术可为合 ...
- TX2超详细,超实用刷机教程(亲测有效,所有步骤都是博主亲自实践过)
https://blog.csdn.net/DeepWolf/article/details/88640937 本篇主要对TX2刷机流程以及刷机过程中遇到的坑和相应的解决办法做个记录,以便再次刷机时能 ...
- webservice 的简单实现
1.什么是webservice: 服务端整出一些资源让客户端访问(获取数据) 一个跨语言.跨平台的规范2.作用:跨平台调用.跨语言调用.远程调用 3.什么时候使用webservice: 1.新旧系统之 ...