first commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package wxrouter
|
||||
|
||||
import (
|
||||
"time"
|
||||
"xiawan/wx/clientsdk"
|
||||
"xiawan/wx/protobuf/wechat"
|
||||
"xiawan/wx/srv/wxcore"
|
||||
"xiawan/wx/srv/wxface"
|
||||
)
|
||||
|
||||
// WXInitContactRouter 初始化联系人响应路由
|
||||
type WXInitContactRouter struct {
|
||||
wxcore.WXBaseRouter
|
||||
}
|
||||
|
||||
// Handle 处理conn业务的方法
|
||||
func (hbr *WXInitContactRouter) Handle(wxResp wxface.IWXResponse) error {
|
||||
currentWXConn := wxResp.GetWXConncet()
|
||||
currentWXAccount := currentWXConn.GetWXAccount()
|
||||
currentUserInfo := currentWXAccount.GetUserInfo()
|
||||
currentWXCache := currentWXConn.GetWXCache()
|
||||
currentReqInvoker := currentWXConn.GetWXReqInvoker()
|
||||
|
||||
// 解析初始化通讯录响应
|
||||
var initContactResp wechat.InitContactResp
|
||||
err := clientsdk.ParseResponseData(currentUserInfo, wxResp.GetPackHeader(), &initContactResp)
|
||||
if err != nil {
|
||||
// 请求出问题了,判断是否掉线,并重连
|
||||
time.Sleep(1 * time.Second)
|
||||
go currentWXConn.CheckOnLineStatusLogin()
|
||||
return err
|
||||
}
|
||||
|
||||
// 设置ContactSeq
|
||||
newContactSeq := initContactResp.GetCurrentWxcontactSeq()
|
||||
currentWXCache.SetContactSeq(newContactSeq)
|
||||
// 判断 联系人数量
|
||||
contactUserNameList := initContactResp.GetContactUsernameList()
|
||||
currentWXCache.AddInitContactWxidList(contactUserNameList)
|
||||
|
||||
if len(contactUserNameList) >= 100 {
|
||||
currentReqInvoker.SendInitContactRequest(newContactSeq)
|
||||
} else {
|
||||
// 初始化通讯录
|
||||
tmpWxidList := currentWXCache.GetNextInitContactWxidList(20)
|
||||
currentReqInvoker.SendBatchGetContactBriefInfoReq(tmpWxidList)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user