- jslogin
- login
- webwxnewloginpage
- webwxinit
- webwxstatusnotify
- webwxgetcontact
- webwxbatchgetcontact
- synccheck
- webwxsync
- webwxsendmsg
- webwxuploadmedia
-
webwxsendmsgimg
三、Daemon 流程本节就不详细分析源码了,在后面章节写api代码时,如果有需要再具体问题具体分析。
有兴趣的同学请自行分析。有问题或者有更好的方法请给我留言交流,共同进步。
在上面的资源列表图中可以看到(注意看最下面三行),和上节登录流程中的 login一样,浏览器每间隔25秒左右就请求一次 synccheck
如果它的返回值不是 window.synccheck={retcode:"0",selector:"0"}
就会触发 webwxsync来修改 SyncKey, 做为下一次向微信服务器请求的凭据
- '1100': 登出微信(可能)
- '1101': 其他设备登录web微信(可能)
- '1102': (暂时不知道)
- webwxgetcontact
- webwxbatchgetcontact
- webwxsendmsg
- webwxsendmsgimg
- (不全,还有其它待补充)
- something.js
// 待办事项队列 先进先出 push shift
let todoList = []
const methods = {
webwxgetcontact () {},
webwxbatchgetcontact () {},
webwxsendmsg () {},
webwxsendmsgimg () {}
}
module.exports = {
do () {
if (todoList.length > 0) {
const { method } = todoList.shift()
methods[method]()
}
},
add (method) {
todoList.push({ method })
}
}
- daemon.js
const something = require('./something.js')
const init = () => {
webwxnewloginpage()
webwxinit()
}
const daemon = {
start () {
// 初始化
init ()
// 通知手机
webwxstatusnotify()
something.add('webwxgetcontact')
while (true) {
// 循环请求 synccheck
const checked = synccheck()
if (!checked) {
// 如果需要就调用 webwxsync
webwxsync()
}
something.do()
}
}
}
- 如果要发送文本消息就调用 something.add('webwxsendmsg')
- 如果要发送图片消息就调用 something.add('webwxsendmsgimg')



