1 Star 0 Fork 9

nzj / 微信小程序Websocket实时通讯

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
BettyW 提交于 2021-08-18 10:12 . goeasy2.1.11
//app.js
import GoEasy from './utils/goeasy-2.1.11.min.js';
App({
globalData: {
goEasy: GoEasy.getInstance({
host:"hangzhou.goeasy.io",//应用所在的区域地址: 【hangzhou.goeasy.io |singapore.goeasy.io】
appkey:"BC-xxxx",// common key
modules: ['pubsub']
})
},
onLaunch: function () {
this.extendDateFormat();
//建立连接
this.globalData.goEasy.connect({
onSuccess: function () {
console.log("GoEasy connect successfully.")
},
onFailed: function (error) {
console.log("Failed to connect GoEasy, code:" + error.code + ",error:" + error.content);
wx.showModal({
icon: "none",
title: error.code.toString(),
content: error.content,
showCancel: false,
duration: 6000
});
},
onProgress: function (attempts) {
console.log("GoEasy is connecting", attempts);
}
});
},
extendDateFormat() {
Date.prototype.formatDate = function (fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (o.hasOwnProperty(k)) {
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
return fmt;
};
}
})
JavaScript
1
https://gitee.com/nzj/GoEasyDemo-wxapp-Helloworld.git
git@gitee.com:nzj/GoEasyDemo-wxapp-Helloworld.git
nzj
GoEasyDemo-wxapp-Helloworld
微信小程序Websocket实时通讯
2.1

搜索帮助