mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
fix session sync timeout.
This commit is contained in:
parent
154ce35198
commit
8c89d62657
@ -153,7 +153,9 @@ func (c *QQClient) c2cMessageSyncProcessor(rsp *msg.GetMessageResponse, info *in
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if delItems != nil {
|
||||||
_, _ = c.sendAndWait(c.buildDeleteMessageRequestPacket(delItems))
|
_, _ = c.sendAndWait(c.buildDeleteMessageRequestPacket(delItems))
|
||||||
|
}
|
||||||
if rsp.GetSyncFlag() != msg.SyncFlag_STOP {
|
if rsp.GetSyncFlag() != msg.SyncFlag_STOP {
|
||||||
c.Debug("continue sync with flag: %v", rsp.SyncFlag.String())
|
c.Debug("continue sync with flag: %v", rsp.SyncFlag.String())
|
||||||
seq, pkt := c.buildGetMessageRequestPacket(rsp.GetSyncFlag(), time.Now().Unix())
|
seq, pkt := c.buildGetMessageRequestPacket(rsp.GetSyncFlag(), time.Now().Unix())
|
||||||
|
@ -73,19 +73,13 @@ func (c *QQClient) RefreshStatus() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) SyncSessions() (*SessionSyncResponse, error) {
|
func (c *QQClient) SyncSessions() (*SessionSyncResponse, error) {
|
||||||
_, pkt := c.buildSyncMsgRequestPacket()
|
|
||||||
if err := c.send(pkt); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ret := &SessionSyncResponse{}
|
ret := &SessionSyncResponse{}
|
||||||
notifyChan := make(chan bool)
|
notifyChan := make(chan bool)
|
||||||
var groupNum int32 = -1
|
var groupNum int32 = -1
|
||||||
p := 0
|
|
||||||
stop := c.waitPacket("RegPrxySvc.PbSyncMsg", func(i interface{}, err error) {
|
stop := c.waitPacket("RegPrxySvc.PbSyncMsg", func(i interface{}, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p++
|
|
||||||
e := i.(*sessionSyncEvent)
|
e := i.(*sessionSyncEvent)
|
||||||
if len(e.GroupSessions) > 0 {
|
if len(e.GroupSessions) > 0 {
|
||||||
ret.GroupSessions = append(ret.GroupSessions, e.GroupSessions...)
|
ret.GroupSessions = append(ret.GroupSessions, e.GroupSessions...)
|
||||||
@ -93,14 +87,20 @@ func (c *QQClient) SyncSessions() (*SessionSyncResponse, error) {
|
|||||||
if e.GroupNum != -1 {
|
if e.GroupNum != -1 {
|
||||||
groupNum = e.GroupNum
|
groupNum = e.GroupNum
|
||||||
}
|
}
|
||||||
|
c.Debug("sync session %v/%v", len(ret.GroupSessions), groupNum)
|
||||||
if groupNum != -1 && len(ret.GroupSessions) >= int(groupNum) {
|
if groupNum != -1 && len(ret.GroupSessions) >= int(groupNum) {
|
||||||
notifyChan <- true
|
notifyChan <- true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
_, pkt := c.buildSyncMsgRequestPacket()
|
||||||
|
if err := c.send(pkt); err != nil {
|
||||||
|
stop()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case <-notifyChan:
|
case <-notifyChan:
|
||||||
stop()
|
stop()
|
||||||
case <-time.After(time.Second * 20):
|
case <-time.After(time.Second * 3):
|
||||||
stop()
|
stop()
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user