first commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package wxrouter
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"xiawan/wx/clientsdk"
|
||||
"xiawan/wx/clientsdk/baseinfo"
|
||||
"xiawan/wx/protobuf/wechat"
|
||||
"xiawan/wx/srv/wxcore"
|
||||
"xiawan/wx/srv/wxface"
|
||||
)
|
||||
|
||||
// WXSnsSyncRouter 同步朋友圈
|
||||
type WXSnsSyncRouter struct {
|
||||
wxcore.WXBaseRouter
|
||||
}
|
||||
|
||||
// Handle 处理conn业务的方法
|
||||
func (ssr *WXSnsSyncRouter) Handle(wxResp wxface.IWXResponse) error {
|
||||
defer wxcore.TryE("WXSnsSyncRouter Handle")
|
||||
|
||||
currentWXConn := wxResp.GetWXConncet()
|
||||
//currentTaskMgr := currentWXConn.GetWXTaskMgr()
|
||||
currentWXAccount := currentWXConn.GetWXAccount()
|
||||
currentUserInfo := currentWXAccount.GetUserInfo()
|
||||
//taskMgr, _ := currentTaskMgr.(*wxcore.WXTaskMgr)
|
||||
//currentSnsTransTask := taskMgr.GetSnsTransTask()
|
||||
currentReqInvoker := currentWXConn.GetWXReqInvoker()
|
||||
// 解析 同步朋友圈响应包
|
||||
var snsSyncResp wechat.SnsSyncResponse
|
||||
err := clientsdk.ParseResponseData(currentUserInfo, wxResp.GetPackHeader(), &snsSyncResp)
|
||||
if err != nil {
|
||||
// 请求出问题了,判断是否掉线,并重连
|
||||
time.Sleep(1 * time.Second)
|
||||
go currentWXConn.CheckOnLineStatusLogin()
|
||||
return err
|
||||
}
|
||||
|
||||
// 如果请求失败
|
||||
retCode := snsSyncResp.GetBaseResponse().GetRet()
|
||||
errMsg := snsSyncResp.GetBaseResponse().GetErrMsg().GetStr()
|
||||
if retCode != baseinfo.MMOk {
|
||||
return errors.New("WXSnsSyncRouter err:" + strconv.Itoa(int(retCode)) + " msg = " + errMsg)
|
||||
}
|
||||
|
||||
// 跟新key
|
||||
currentUserInfo.SnsSyncKey = snsSyncResp.GetKeyBuf().GetBuffer()
|
||||
// 遍历同步到的朋友圈
|
||||
tmpCmdList := snsSyncResp.GetCmdList()
|
||||
tmpCount := tmpCmdList.GetCount()
|
||||
if tmpCount > 0 {
|
||||
_, _ = currentReqInvoker.SendSnsSyncRequest(true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user