24 changed files with 186 additions and 7864 deletions
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 220 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
var dispCbs = []; |
||||
var dispIns = []; |
||||
|
||||
function Dispatcher() { |
||||
dispIns.push(this); |
||||
dispCbs.push({}); |
||||
} |
||||
|
||||
Dispatcher.prototype = { |
||||
on(type, cb) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
if (!~cbs.indexOf(cb)) { |
||||
cbs.push(cb); |
||||
} |
||||
}, |
||||
|
||||
off(type, cb) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
let curTypeCbIdx = cbs.indexOf(cb); |
||||
if (~curTypeCbIdx) { |
||||
cbs.splice(curTypeCbIdx, 1); |
||||
} |
||||
}, |
||||
|
||||
fire(type, ...args) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
|
||||
for (let i = 0; i < cbs.length; i++) { |
||||
cbs[i].apply(null, args); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
module.exports = Dispatcher; |
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
var obsCbs = obsCbs || []; |
||||
var obsObjs = obsObjs || []; |
||||
var cloneObjs = cloneObjs || []; |
||||
|
||||
function newOne(obj){ |
||||
obsObjs.push(obj); |
||||
obsCbs.push([]); |
||||
cloneObjs.push(Object.assign({}, obj)); |
||||
} |
||||
|
||||
module.exports = { |
||||
del(obj, cb){ |
||||
let curObjIdx = obsObjs.indexOf(obj); |
||||
if(~curObjIdx){ |
||||
let cbs = obsCbs[curObjIdx]; |
||||
let curCbIdx = cbs.indexOf(cb); |
||||
if(~curCbIdx){ |
||||
cbs.splice(curCbIdx, 1); |
||||
if(!cbs.length){ |
||||
obsObjs.splice(curObjIdx, 1); |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
add(obj, cb){ |
||||
let curIdx = obsObjs.indexOf(obj); |
||||
if(!~curIdx){ |
||||
curIdx = obsObjs.length; |
||||
newOne(obj); |
||||
} |
||||
let cbs = obsCbs[curIdx]; |
||||
cbs.push(cb); |
||||
for(let key in obj){ |
||||
Object.defineProperty(obj, key, { |
||||
set: function(val){ |
||||
cloneObjs[curIdx][key] = val; |
||||
for(let i = 0; i < cbs.length; i++){ |
||||
cbs[i].apply(obj, [val, key]); |
||||
} |
||||
}, |
||||
get: function(){ |
||||
return cloneObjs[curIdx][key]; |
||||
} |
||||
}); |
||||
} |
||||
return obj; |
||||
}, |
||||
}; |
@ -1,266 +0,0 @@
@@ -1,266 +0,0 @@
|
||||
import websdk from "@/sdk/Easemob-chat-4.3.1"; |
||||
import config from "./WebIMConfig"; |
||||
|
||||
console.group = console.group || {}; |
||||
console.groupEnd = console.groupEnd || {}; |
||||
|
||||
const window = {}; |
||||
const WebIM = window.WebIM = websdk; |
||||
WebIM.message = websdk.message |
||||
window.WebIM.config = config; |
||||
//var DOMParser = window.DOMParser = xmldom.DOMParser;
|
||||
//let document = window.document = new DOMParser().parseFromString("<?xml version='1.0'?>\n", "text/xml");
|
||||
|
||||
WebIM.isDebug = function (option) { |
||||
if (option) { |
||||
WebIM.config.isDebug = option.isDebug |
||||
openDebug(WebIM.config.isDebug) |
||||
} |
||||
|
||||
function openDebug(value) { |
||||
function ts() { |
||||
const d = new Date(); |
||||
const Hours = d.getHours(); // 获取当前小时数(0-23)
|
||||
const Minutes = d.getMinutes(); // 获取当前分钟数(0-59)
|
||||
const Seconds = d.getSeconds(); // 获取当前秒数(0-59)
|
||||
return `${Hours < 10 ? `0${ Hours}` : Hours }:${ Minutes < 10 ? `0${ Minutes}` : Minutes }:${ Seconds < 10 ? `0${ Seconds}` : Seconds } `; |
||||
} |
||||
|
||||
|
||||
// if (value) {
|
||||
// Strophe.Strophe.Connection.prototype.rawOutput = function(data){
|
||||
// try{
|
||||
// console.group("%csend # " + ts(), "color: blue; font-size: large");
|
||||
// console.log("%c" + data, "color: blue");
|
||||
// console.groupEnd();
|
||||
// }
|
||||
// catch(e){
|
||||
// console.log(e);
|
||||
// }
|
||||
// };
|
||||
// }else{
|
||||
// Strophe.Strophe.Connection.prototype.rawOutput = function(){};
|
||||
// }
|
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Set autoSignIn as true (autoSignInName and autoSignInPwd are configured below), |
||||
* You can auto signed in each time when you refresh the page in dev model. |
||||
*/ |
||||
WebIM.config.autoSignIn = false; |
||||
if (WebIM.config.autoSignIn) { |
||||
WebIM.config.autoSignInName = "lwz2"; |
||||
WebIM.config.autoSignInPwd = "1"; |
||||
} |
||||
|
||||
|
||||
// var stropheConn = new window.Strophe.Connection("ws://im-api.easemob.com/ws/", {
|
||||
// inactivity: 30,
|
||||
// maxRetries: 5,
|
||||
// pollingTime: 4500
|
||||
// });
|
||||
//
|
||||
// stropheConn.connect(
|
||||
// '$t$' + 'YWMtmbQEBKKIEeaGmMtXyg5n1wAAAVlkQvGO2WOJGlMCEJKM4VV9GCMnb_XLCXU',
|
||||
// function() {
|
||||
// console.log(arguments, 'ggogogo');
|
||||
// }, stropheConn.wait, stropheConn.hold);
|
||||
WebIM.parseEmoji = function (msg) { |
||||
if (typeof WebIM.Emoji === "undefined" || typeof WebIM.Emoji.map === "undefined") { |
||||
return msg; |
||||
} |
||||
const emoji = WebIM.Emoji; |
||||
var reg = null; |
||||
const msgList = []; |
||||
const objList = []; |
||||
for (const face in emoji.map) { |
||||
if (emoji.map.hasOwnProperty(face)) { |
||||
while (msg.includes(face)) { |
||||
msg = msg.replace(face, `^${ emoji.map[face] }^`); |
||||
} |
||||
} |
||||
} |
||||
const ary = msg.split("^"); |
||||
var reg = /^e.*g$/; |
||||
for (var i = 0; i < ary.length; i++) { |
||||
if (ary[i] != "") { |
||||
msgList.push(ary[i]); |
||||
} |
||||
} |
||||
for (var i = 0; i < msgList.length; i++) { |
||||
if (reg.test(msgList[i])) { |
||||
var obj = {}; |
||||
obj.data = msgList[i]; |
||||
obj.type = "emoji"; |
||||
objList.push(obj); |
||||
} |
||||
else { |
||||
var obj = {}; |
||||
obj.data = msgList[i]; |
||||
obj.type = "txt"; |
||||
objList.push(obj); |
||||
} |
||||
} |
||||
return objList; |
||||
}; |
||||
|
||||
WebIM.time = function () { |
||||
const date = new Date(); |
||||
const Hours = date.getHours(); |
||||
const Minutes = date.getMinutes(); |
||||
const Seconds = date.getSeconds(); |
||||
const time = `${date.getFullYear() }-${ date.getMonth() + 1 }-${ date.getDate() } ${ |
||||
Hours < 10 ? `0${ Hours}` : Hours }:${ Minutes < 10 ? `0${ Minutes}` : Minutes }:${ Seconds < 10 ? `0${ Seconds}` : Seconds}`;
|
||||
return time; |
||||
}; |
||||
|
||||
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", |
||||
"[<o)]": "ee_12.png", |
||||
"[(a)]": "ee_13.png", |
||||
"[8o|]": "ee_14.png", |
||||
"[8-|]": "ee_15.png", |
||||
"[+o(]": "ee_16.png", |
||||
"[|-)]": "ee_17.png", |
||||
"[:|]": "ee_18.png", |
||||
"[*-)]": "ee_19.png", |
||||
"[:-#]": "ee_20.png", |
||||
"[^o)]": "ee_21.png", |
||||
"[:-*]": "ee_22.png", |
||||
"[8-)]": "ee_23.png", |
||||
"[del]": "btn_del.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.EmojiObj = { |
||||
// 相对 emoji.js 路径
|
||||
path: "../../../../../images/faces/", |
||||
map1: { |
||||
"[):]": "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" |
||||
}, |
||||
map2: { |
||||
"[:s]": "ee_8.png", |
||||
"[:$]": "ee_9.png", |
||||
"[:(]": "ee_10.png", |
||||
"[:'(]": "ee_11.png", |
||||
"[<o)]": "ee_12.png", |
||||
"[(a)]": "ee_13.png", |
||||
"[8o|]": "ee_14.png" |
||||
}, |
||||
map3: { |
||||
"[8-|]": "ee_15.png", |
||||
"[+o(]": "ee_16.png", |
||||
"[|-)]": "ee_17.png", |
||||
"[:|]": "ee_18.png", |
||||
"[*-)]": "ee_19.png", |
||||
"[:-#]": "ee_20.png", |
||||
"[del]": "del.png" |
||||
}, |
||||
map4: { |
||||
"[^o)]": "ee_21.png", |
||||
"[:-*]": "ee_22.png", |
||||
"[8-)]": "ee_23.png", |
||||
"[(|)]": "ee_24.png", |
||||
"[(u)]": "ee_25.png", |
||||
"[(S)]": "ee_26.png", |
||||
"[(*)]": "ee_27.png" |
||||
}, |
||||
map5: { |
||||
"[(#)]": "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" |
||||
}, |
||||
map6: { |
||||
"[del]": "del.png" |
||||
} |
||||
}; |
||||
|
||||
|
||||
WebIM.conn = new WebIM.connection({ |
||||
appKey: WebIM.config.appkey, |
||||
isMultiLoginSessions: WebIM.config.isMultiLoginSessions, |
||||
https: true, //typeof WebIM.config.https === "boolean" ? WebIM.config.https : location.protocol === "https:",
|
||||
url: WebIM.config.socketServer, |
||||
apiUrl: WebIM.config.apiURL, |
||||
isAutoLogin: false, |
||||
heartBeatWait: 30000, //WebIM.config.heartBeatWait,
|
||||
autoReconnectNumMax: WebIM.config.autoReconnectNumMax, |
||||
autoReconnectInterval: WebIM.config.autoReconnectInterval, |
||||
isDebug: WebIM.config.isDebug, |
||||
deviceId: WebIM.config.deviceId |
||||
}); |
||||
|
||||
// async response
|
||||
// WebIM.conn.listen({
|
||||
// onOpened: () => dispatch({type: Types.ON_OPEND})
|
||||
// })
|
||||
Math.uuid = function (len, radix) { |
||||
const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); |
||||
const chars = CHARS; const uuid = []; let i; |
||||
radix = radix || chars.length; |
||||
|
||||
if (len) { |
||||
// Compact form
|
||||
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; |
||||
} else { |
||||
// rfc4122, version 4 form
|
||||
let r; |
||||
|
||||
// rfc4122 requires these characters
|
||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; |
||||
uuid[14] = '4'; |
||||
|
||||
// Fill in random data. At i==19 set the high bits of clock sequence
|
||||
// as
|
||||
// per rfc4122, sec. 4.1.5
|
||||
for (i = 0; i < 36; i++) { |
||||
if (!uuid[i]) { |
||||
r = 0 | Math.random() * 16; |
||||
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return uuid.join(''); |
||||
}; |
||||
// export default WebIM;
|
||||
module.exports = { |
||||
"default": WebIM |
||||
}; |
@ -1,88 +0,0 @@
@@ -1,88 +0,0 @@
|
||||
/** |
||||
* git do not control webim.config.js |
||||
* everyone should copy webim.config.js to webim.config.js |
||||
* and have their own configs. |
||||
* In this way , others won't be influenced by this config while git pull. |
||||
* |
||||
*/ |
||||
|
||||
// for react native
|
||||
const location = { |
||||
protocol: "https", |
||||
}; |
||||
|
||||
const config = { |
||||
/* |
||||
* socket server |
||||
*/ |
||||
// socketServer: "wss://im-api.easemob.com/ws/", //小程序2.0sdk线上环境 请使用2.0版本sdk
|
||||
// socketServer: "wss://im-api-hsb.easemob.com/ws/", //小程序2.0sdk沙箱环境 请使用2.0版本sdk
|
||||
// socketServer: 'wss://im-api-new-hsb.easemob.com/websocket', //小程序沙箱环境
|
||||
socketServer: "wss://im-api-wechat.easemob.com/websocket", //小程序线上环境
|
||||
// socketServer: 'wss://hk-wx.easemob.com/websocket',
|
||||
/* |
||||
* Backend REST API URL |
||||
*/ |
||||
// apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com',
|
||||
apiURL: "https://a1.easemob.com", // 线上环境
|
||||
// apiURL: "https://a1-hsb.easemob.com", // 沙箱环境
|
||||
// apiURL: 'https://hk-test.easemob.com',
|
||||
/* |
||||
* Application AppKey |
||||
*/ |
||||
appkey: "1110180510146396#dream", |
||||
/* |
||||
* Whether to use HTTPS '1177161227178308#xcx' |
||||
* @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, |
||||
/** |
||||
* 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: 5, |
||||
/** |
||||
* the interval secons between each atuo reconnectting. |
||||
* works only if autoReconnectMaxNum >= 2. |
||||
*/ |
||||
autoReconnectInterval: 2, |
||||
/** |
||||
* webrtc supports WebKit and https only |
||||
*/ |
||||
isWebRTC: false, |
||||
/* |
||||
* Set to auto sign-in |
||||
*/ |
||||
isAutoLogin: true, |
||||
|
||||
heartBeatWait: 30000, |
||||
|
||||
/* |
||||
* 需要替换成自己的声网 appId,此 appId 有限量,仅供参考使用,同时获取声网 token 的接口仅能供此 appId 使用,换成自己的 appId 后需要自己去实现 app server 获取声网token。 |
||||
*/ |
||||
AgoraAppId: "15cb0d28b87b425ea613fc46f7c9f974", |
||||
}; |
||||
|
||||
export default config; |
Loading…
Reference in new issue