fix: reinstall app sync data split.
This commit is contained in:
parent
b162725bd6
commit
f0bd767d81
@ -38,7 +38,6 @@ func (c *Conversation) Work(c2v common.Cmd2Value) {
|
|||||||
switch c2v.Cmd {
|
switch c2v.Cmd {
|
||||||
case constant.CmdNewMsgCome:
|
case constant.CmdNewMsgCome:
|
||||||
c.doMsgNew(c2v)
|
c.doMsgNew(c2v)
|
||||||
case constant.CmdSuperGroupMsgCome:
|
|
||||||
case constant.CmdUpdateConversation:
|
case constant.CmdUpdateConversation:
|
||||||
c.doUpdateConversation(c2v)
|
c.doUpdateConversation(c2v)
|
||||||
case constant.CmdUpdateMessage:
|
case constant.CmdUpdateMessage:
|
||||||
@ -54,26 +53,54 @@ func (c *Conversation) doNotificationNew(c2v common.Cmd2Value) {
|
|||||||
allMsg := c2v.Value.(sdk_struct.CmdNewMsgComeToConversation).Msgs
|
allMsg := c2v.Value.(sdk_struct.CmdNewMsgComeToConversation).Msgs
|
||||||
syncFlag := c2v.Value.(sdk_struct.CmdNewMsgComeToConversation).SyncFlag
|
syncFlag := c2v.Value.(sdk_struct.CmdNewMsgComeToConversation).SyncFlag
|
||||||
switch syncFlag {
|
switch syncFlag {
|
||||||
case constant.MsgSyncBegin:
|
case constant.AppDataSyncStart:
|
||||||
|
log.ZDebug(ctx, "AppDataSyncStart")
|
||||||
c.startTime = time.Now()
|
c.startTime = time.Now()
|
||||||
c.ConversationListener().OnSyncServerStart()
|
c.ConversationListener().OnSyncServerStart(true)
|
||||||
if err := c.SyncAllConversationHashReadSeqs(ctx); err != nil {
|
syncFunctions := []func(c context.Context) error{
|
||||||
log.ZError(ctx, "SyncConversationHashReadSeqs err", err)
|
c.SyncAllConversationHashReadSeqs,
|
||||||
|
c.user.SyncLoginUserInfoWithoutNotice,
|
||||||
|
c.friend.SyncAllBlackListWithoutNotice,
|
||||||
|
c.friend.SyncAllFriendApplicationWithoutNotice,
|
||||||
|
c.friend.SyncAllSelfFriendApplicationWithoutNotice,
|
||||||
|
c.group.SyncAllAdminGroupApplicationWithoutNotice,
|
||||||
|
c.group.SyncAllSelfGroupApplicationWithoutNotice,
|
||||||
|
c.user.SyncAllCommandWithoutNotice,
|
||||||
|
c.group.SyncAllJoinedGroupsAndMembers,
|
||||||
|
c.friend.IncrSyncFriends,
|
||||||
|
c.SyncAllConversationsWithoutNotice,
|
||||||
}
|
}
|
||||||
|
totalFunctions := len(syncFunctions)
|
||||||
|
for i, syncFunc := range syncFunctions {
|
||||||
|
funcName := runtime.FuncForPC(reflect.ValueOf(syncFunc).Pointer()).Name()
|
||||||
|
startTime := time.Now()
|
||||||
|
err := syncFunc(ctx)
|
||||||
|
duration := time.Since(startTime)
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, fmt.Sprintf("%s sync err", funcName), err, "duration", duration.Seconds())
|
||||||
|
} else {
|
||||||
|
log.ZDebug(ctx, fmt.Sprintf("%s completed successfully", funcName), "duration", duration.Seconds())
|
||||||
|
}
|
||||||
|
progress := int(float64(i+1) / float64(totalFunctions) * 100)
|
||||||
|
if progress == 0 {
|
||||||
|
progress = 1
|
||||||
|
}
|
||||||
|
c.ConversationListener().OnSyncServerProgress(progress)
|
||||||
|
}
|
||||||
|
case constant.AppDataSyncFinish:
|
||||||
|
log.ZDebug(ctx, "AppDataSyncFinish", "time", time.Since(c.startTime).Milliseconds())
|
||||||
|
c.ConversationListener().OnSyncServerFailed(true)
|
||||||
|
case constant.MsgSyncBegin:
|
||||||
|
log.ZDebug(ctx, "MsgSyncBegin")
|
||||||
|
c.startTime = time.Now()
|
||||||
|
c.ConversationListener().OnSyncServerStart(false)
|
||||||
//clear SubscriptionStatusMap
|
//clear SubscriptionStatusMap
|
||||||
c.user.OnlineStatusCache.DeleteAll()
|
c.user.OnlineStatusCache.DeleteAll()
|
||||||
for _, syncFunc := range []func(c context.Context) error{
|
|
||||||
c.user.SyncLoginUserInfo,
|
|
||||||
c.friend.SyncAllBlackList, c.friend.SyncAllFriendApplication, c.friend.SyncAllSelfFriendApplication,
|
|
||||||
c.group.SyncAllAdminGroupApplication, c.group.SyncAllSelfGroupApplication, c.user.SyncAllCommand,
|
|
||||||
} {
|
|
||||||
go func(syncFunc func(c context.Context) error) {
|
|
||||||
_ = syncFunc(ctx)
|
|
||||||
}(syncFunc)
|
|
||||||
}
|
|
||||||
|
|
||||||
syncFunctions := []func(c context.Context) error{
|
syncFunctions := []func(c context.Context) error{
|
||||||
c.group.SyncAllJoinedGroupsAndMembers, c.friend.IncrSyncFriends, c.SyncAllConversations,
|
c.SyncAllConversationHashReadSeqs,
|
||||||
|
c.group.SyncAllJoinedGroupsAndMembers,
|
||||||
|
c.friend.IncrSyncFriends,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, syncFunc := range syncFunctions {
|
for _, syncFunc := range syncFunctions {
|
||||||
@ -87,11 +114,29 @@ func (c *Conversation) doNotificationNew(c2v common.Cmd2Value) {
|
|||||||
log.ZDebug(ctx, fmt.Sprintf("%s completed successfully", funcName), "duration", duration.Seconds())
|
log.ZDebug(ctx, fmt.Sprintf("%s completed successfully", funcName), "duration", duration.Seconds())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, syncFunc := range []func(c context.Context) error{
|
||||||
|
c.user.SyncLoginUserInfo,
|
||||||
|
c.friend.SyncAllBlackList, c.friend.SyncAllFriendApplication, c.friend.SyncAllSelfFriendApplication,
|
||||||
|
c.group.SyncAllAdminGroupApplication, c.group.SyncAllSelfGroupApplication, c.user.SyncAllCommand, c.SyncAllConversations,
|
||||||
|
} {
|
||||||
|
go func(syncFunc func(c context.Context) error) {
|
||||||
|
funcName := runtime.FuncForPC(reflect.ValueOf(syncFunc).Pointer()).Name()
|
||||||
|
startTime := time.Now()
|
||||||
|
err := syncFunc(ctx)
|
||||||
|
duration := time.Since(startTime)
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, fmt.Sprintf("%s sync err", funcName), err, "duration", duration.Seconds())
|
||||||
|
} else {
|
||||||
|
log.ZDebug(ctx, fmt.Sprintf("%s completed successfully", funcName), "duration", duration.Seconds())
|
||||||
|
}
|
||||||
|
}(syncFunc)
|
||||||
|
}
|
||||||
|
|
||||||
case constant.MsgSyncFailed:
|
case constant.MsgSyncFailed:
|
||||||
c.ConversationListener().OnSyncServerFailed()
|
c.ConversationListener().OnSyncServerFailed(false)
|
||||||
case constant.MsgSyncEnd:
|
case constant.MsgSyncEnd:
|
||||||
log.ZDebug(ctx, "MsgSyncEnd", "time", time.Since(c.startTime).Milliseconds())
|
log.ZDebug(ctx, "MsgSyncEnd", "time", time.Since(c.startTime).Milliseconds())
|
||||||
defer c.ConversationListener().OnSyncServerFinish()
|
c.ConversationListener().OnSyncServerFinish(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
for conversationID, msgs := range allMsg {
|
for conversationID, msgs := range allMsg {
|
||||||
|
@ -50,7 +50,7 @@ func (m *MessageController) BatchUpdateMessageList(ctx context.Context, updateMs
|
|||||||
latestMsg := &sdk_struct.MsgStruct{}
|
latestMsg := &sdk_struct.MsgStruct{}
|
||||||
if err := json.Unmarshal([]byte(conversation.LatestMsg), latestMsg); err != nil {
|
if err := json.Unmarshal([]byte(conversation.LatestMsg), latestMsg); err != nil {
|
||||||
log.ZError(ctx, "Unmarshal err", err, "conversationID",
|
log.ZError(ctx, "Unmarshal err", err, "conversationID",
|
||||||
conversationID, "latestMsg", conversation.LatestMsg)
|
conversationID, "latestMsg", conversation.LatestMsg, "messages", messages)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, v := range messages {
|
for _, v := range messages {
|
||||||
|
@ -54,6 +54,16 @@ func (c *Conversation) SyncConversations(ctx context.Context, conversationIDs []
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conversation) SyncAllConversations(ctx context.Context) error {
|
func (c *Conversation) SyncAllConversations(ctx context.Context) error {
|
||||||
|
ccTime := time.Now()
|
||||||
|
conversationsOnServer, err := c.getServerConversationList(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.ZDebug(ctx, "get server cost time", "cost time", time.Since(ccTime), "conversation on server", conversationsOnServer)
|
||||||
|
return c.SyncConversationsAndTriggerCallback(ctx, conversationsOnServer, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conversation) SyncAllConversationsWithoutNotice(ctx context.Context) error {
|
||||||
ccTime := time.Now()
|
ccTime := time.Now()
|
||||||
conversationsOnServer, err := c.getServerConversationList(ctx)
|
conversationsOnServer, err := c.getServerConversationList(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -64,25 +74,34 @@ func (c *Conversation) SyncAllConversations(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conversation) SyncAllConversationHashReadSeqs(ctx context.Context) error {
|
func (c *Conversation) SyncAllConversationHashReadSeqs(ctx context.Context) error {
|
||||||
|
startTime := time.Now()
|
||||||
log.ZDebug(ctx, "start SyncConversationHashReadSeqs")
|
log.ZDebug(ctx, "start SyncConversationHashReadSeqs")
|
||||||
|
|
||||||
seqs, err := c.getServerHasReadAndMaxSeqs(ctx)
|
seqs, err := c.getServerHasReadAndMaxSeqs(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "getServerHasReadAndMaxSeqs completed", "duration", time.Since(startTime).Seconds())
|
||||||
|
|
||||||
if len(seqs) == 0 {
|
if len(seqs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var conversationChangedIDs []string
|
var conversationChangedIDs []string
|
||||||
var conversationIDsNeedSync []string
|
var conversationIDsNeedSync []string
|
||||||
|
|
||||||
|
stepStartTime := time.Now()
|
||||||
conversationsOnLocal, err := c.db.GetAllConversations(ctx)
|
conversationsOnLocal, err := c.db.GetAllConversations(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "get all conversations err", err)
|
log.ZWarn(ctx, "get all conversations err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "GetAllConversations completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
|
|
||||||
conversationsOnLocalMap := datautil.SliceToMap(conversationsOnLocal, func(e *model_struct.LocalConversation) string {
|
conversationsOnLocalMap := datautil.SliceToMap(conversationsOnLocal, func(e *model_struct.LocalConversation) string {
|
||||||
return e.ConversationID
|
return e.ConversationID
|
||||||
})
|
})
|
||||||
|
|
||||||
|
stepStartTime = time.Now()
|
||||||
for conversationID, v := range seqs {
|
for conversationID, v := range seqs {
|
||||||
var unreadCount int32
|
var unreadCount int32
|
||||||
c.maxSeqRecorder.Set(conversationID, v.MaxSeq)
|
c.maxSeqRecorder.Set(conversationID, v.MaxSeq)
|
||||||
@ -104,18 +123,24 @@ func (c *Conversation) SyncAllConversationHashReadSeqs(ctx context.Context) erro
|
|||||||
} else {
|
} else {
|
||||||
conversationIDsNeedSync = append(conversationIDsNeedSync, conversationID)
|
conversationIDsNeedSync = append(conversationIDsNeedSync, conversationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "Process seqs completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
|
|
||||||
if len(conversationIDsNeedSync) > 0 {
|
if len(conversationIDsNeedSync) > 0 {
|
||||||
|
stepStartTime = time.Now()
|
||||||
conversationsOnServer, err := c.getServerConversationsByIDs(ctx, conversationIDsNeedSync)
|
conversationsOnServer, err := c.getServerConversationsByIDs(ctx, conversationIDsNeedSync)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "getServerConversationsByIDs err", err, "conversationIDs", conversationIDsNeedSync)
|
log.ZWarn(ctx, "getServerConversationsByIDs err", err, "conversationIDs", conversationIDsNeedSync)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "getServerConversationsByIDs completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
|
|
||||||
|
stepStartTime = time.Now()
|
||||||
if err := c.batchAddFaceURLAndName(ctx, conversationsOnServer...); err != nil {
|
if err := c.batchAddFaceURLAndName(ctx, conversationsOnServer...); err != nil {
|
||||||
log.ZWarn(ctx, "batchAddFaceURLAndName err", err, "conversationsOnServer", conversationsOnServer)
|
log.ZWarn(ctx, "batchAddFaceURLAndName err", err, "conversationsOnServer", conversationsOnServer)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "batchAddFaceURLAndName completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
|
|
||||||
for _, conversation := range conversationsOnServer {
|
for _, conversation := range conversationsOnServer {
|
||||||
var unreadCount int32
|
var unreadCount int32
|
||||||
@ -132,17 +157,23 @@ func (c *Conversation) SyncAllConversationHashReadSeqs(ctx context.Context) erro
|
|||||||
conversation.UnreadCount = unreadCount
|
conversation.UnreadCount = unreadCount
|
||||||
conversation.HasReadSeq = v.HasReadSeq
|
conversation.HasReadSeq = v.HasReadSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stepStartTime = time.Now()
|
||||||
err = c.db.BatchInsertConversationList(ctx, conversationsOnServer)
|
err = c.db.BatchInsertConversationList(ctx, conversationsOnServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "BatchInsertConversationList err", err, "conversationsOnServer", conversationsOnServer)
|
log.ZWarn(ctx, "BatchInsertConversationList err", err, "conversationsOnServer", conversationsOnServer)
|
||||||
}
|
}
|
||||||
|
log.ZDebug(ctx, "BatchInsertConversationList completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(ctx, "update conversations", "conversations", conversationChangedIDs)
|
log.ZDebug(ctx, "update conversations", "conversations", conversationChangedIDs)
|
||||||
if len(conversationChangedIDs) > 0 {
|
if len(conversationChangedIDs) > 0 {
|
||||||
|
stepStartTime = time.Now()
|
||||||
common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.ConChange, Args: conversationChangedIDs}, c.GetCh())
|
common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.ConChange, Args: conversationChangedIDs}, c.GetCh())
|
||||||
common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.TotalUnreadMessageChanged}, c.GetCh())
|
common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.TotalUnreadMessageChanged}, c.GetCh())
|
||||||
|
log.ZDebug(ctx, "TriggerCmdUpdateConversation completed", "duration", time.Since(stepStartTime).Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.ZDebug(ctx, "SyncAllConversationHashReadSeqs completed", "totalDuration", time.Since(startTime).Seconds())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,22 @@ func (f *Friend) SyncAllSelfFriendApplication(ctx context.Context) error {
|
|||||||
return f.requestSendSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil)
|
return f.requestSendSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Friend) SyncAllSelfFriendApplicationWithoutNotice(ctx context.Context) error {
|
||||||
|
req := &friend.GetPaginationFriendsApplyFromReq{UserID: f.loginUserID, Pagination: &sdkws.RequestPagination{}}
|
||||||
|
fn := func(resp *friend.GetPaginationFriendsApplyFromResp) []*sdkws.FriendRequest {
|
||||||
|
return resp.FriendRequests
|
||||||
|
}
|
||||||
|
requests, err := util.GetPageAll(ctx, constant.GetSelfFriendApplicationListRouter, req, fn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localData, err := f.db.GetSendFriendApplication(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return f.requestSendSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
// recv
|
// recv
|
||||||
func (f *Friend) SyncAllFriendApplication(ctx context.Context) error {
|
func (f *Friend) SyncAllFriendApplication(ctx context.Context) error {
|
||||||
req := &friend.GetPaginationFriendsApplyToReq{UserID: f.loginUserID, Pagination: &sdkws.RequestPagination{}}
|
req := &friend.GetPaginationFriendsApplyToReq{UserID: f.loginUserID, Pagination: &sdkws.RequestPagination{}}
|
||||||
@ -75,6 +91,19 @@ func (f *Friend) SyncAllFriendApplication(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
return f.requestRecvSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil)
|
return f.requestRecvSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil)
|
||||||
}
|
}
|
||||||
|
func (f *Friend) SyncAllFriendApplicationWithoutNotice(ctx context.Context) error {
|
||||||
|
req := &friend.GetPaginationFriendsApplyToReq{UserID: f.loginUserID, Pagination: &sdkws.RequestPagination{}}
|
||||||
|
fn := func(resp *friend.GetPaginationFriendsApplyToResp) []*sdkws.FriendRequest { return resp.FriendRequests }
|
||||||
|
requests, err := util.GetPageAll(ctx, constant.GetFriendApplicationListRouter, req, fn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localData, err := f.db.GetRecvFriendApplication(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return f.requestRecvSyncer.Sync(ctx, datautil.Batch(ServerFriendRequestToLocalFriendRequest, requests), localData, nil, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Friend) SyncAllFriendList(ctx context.Context) error {
|
func (f *Friend) SyncAllFriendList(ctx context.Context) error {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
@ -171,6 +200,22 @@ func (f *Friend) SyncAllBlackList(ctx context.Context) error {
|
|||||||
return f.blockSyncer.Sync(ctx, datautil.Batch(ServerBlackToLocalBlack, serverData), localData, nil)
|
return f.blockSyncer.Sync(ctx, datautil.Batch(ServerBlackToLocalBlack, serverData), localData, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Friend) SyncAllBlackListWithoutNotice(ctx context.Context) error {
|
||||||
|
req := &friend.GetPaginationBlacksReq{UserID: f.loginUserID, Pagination: &sdkws.RequestPagination{}}
|
||||||
|
fn := func(resp *friend.GetPaginationBlacksResp) []*sdkws.BlackInfo { return resp.Blacks }
|
||||||
|
serverData, err := util.GetPageAll(ctx, constant.GetBlackListRouter, req, fn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.ZDebug(ctx, "black from server", "data", serverData)
|
||||||
|
localData, err := f.db.GetBlackListDB(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.ZDebug(ctx, "black from local", "data", localData)
|
||||||
|
return f.blockSyncer.Sync(ctx, datautil.Batch(ServerBlackToLocalBlack, serverData), localData, nil, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Friend) GetDesignatedFriends(ctx context.Context, friendIDs []string) ([]*sdkws.FriendInfo, error) {
|
func (f *Friend) GetDesignatedFriends(ctx context.Context, friendIDs []string) ([]*sdkws.FriendInfo, error) {
|
||||||
resp := &friend.GetDesignatedFriendsResp{}
|
resp := &friend.GetDesignatedFriendsResp{}
|
||||||
if err := util.ApiPost(ctx, constant.GetDesignatedFriendsRouter, &friend.GetDesignatedFriendsReq{OwnerUserID: f.loginUserID, FriendUserIDs: friendIDs}, &resp); err != nil {
|
if err := util.ApiPost(ctx, constant.GetDesignatedFriendsRouter, &friend.GetDesignatedFriendsReq{OwnerUserID: f.loginUserID, FriendUserIDs: friendIDs}, &resp); err != nil {
|
||||||
|
@ -246,6 +246,22 @@ func (g *Group) SyncAllSelfGroupApplication(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Group) SyncAllSelfGroupApplicationWithoutNotice(ctx context.Context) error {
|
||||||
|
list, err := g.GetServerSelfGroupApplication(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localData, err := g.db.GetSendGroupApplication(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := g.groupRequestSyncer.Sync(ctx, datautil.Batch(ServerGroupRequestToLocalGroupRequest, list), localData, nil, false, true); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// todo
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Group) SyncSelfGroupApplications(ctx context.Context, groupIDs ...string) error {
|
func (g *Group) SyncSelfGroupApplications(ctx context.Context, groupIDs ...string) error {
|
||||||
return g.SyncAllSelfGroupApplication(ctx)
|
return g.SyncAllSelfGroupApplication(ctx)
|
||||||
}
|
}
|
||||||
@ -262,6 +278,18 @@ func (g *Group) SyncAllAdminGroupApplication(ctx context.Context) error {
|
|||||||
return g.groupAdminRequestSyncer.Sync(ctx, datautil.Batch(ServerGroupRequestToLocalAdminGroupRequest, requests), localData, nil)
|
return g.groupAdminRequestSyncer.Sync(ctx, datautil.Batch(ServerGroupRequestToLocalAdminGroupRequest, requests), localData, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Group) SyncAllAdminGroupApplicationWithoutNotice(ctx context.Context) error {
|
||||||
|
requests, err := g.GetServerAdminGroupApplicationList(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localData, err := g.db.GetAdminGroupApplication(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return g.groupAdminRequestSyncer.Sync(ctx, datautil.Batch(ServerGroupRequestToLocalAdminGroupRequest, requests), localData, nil, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Group) SyncAdminGroupApplications(ctx context.Context, groupIDs ...string) error {
|
func (g *Group) SyncAdminGroupApplications(ctx context.Context, groupIDs ...string) error {
|
||||||
return g.SyncAllAdminGroupApplication(ctx)
|
return g.SyncAllAdminGroupApplication(ctx)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package interaction
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/db/model_struct"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/openimsdk/openim-sdk-core/v3/pkg/common"
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/common"
|
||||||
@ -148,15 +149,31 @@ func (m *MsgSyncer) compareSeqsAndBatchSync(ctx context.Context, maxSeqToSync ma
|
|||||||
messagesSeqMap[conversationID] = seq
|
messagesSeqMap[conversationID] = seq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notificationSeqs []*model_struct.NotificationSeqs
|
||||||
|
|
||||||
for conversationID, seq := range notificationsSeqMap {
|
for conversationID, seq := range notificationsSeqMap {
|
||||||
err := m.db.SetNotificationSeq(ctx, conversationID, seq)
|
notificationSeqs = append(notificationSeqs, &model_struct.NotificationSeqs{
|
||||||
if err != nil {
|
ConversationID: conversationID,
|
||||||
log.ZWarn(ctx, "SetNotificationSeq err", err, "conversationID", conversationID, "seq", seq)
|
Seq: seq,
|
||||||
continue
|
})
|
||||||
} else {
|
|
||||||
m.syncedMaxSeqs[conversationID] = seq
|
m.syncedMaxSeqs[conversationID] = seq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err := m.db.BatchInsertNotificationSeq(ctx, notificationSeqs)
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, "BatchInsertNotificationSeq err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for conversationID, seq := range notificationsSeqMap {
|
||||||
|
// err := m.db.SetNotificationSeq(ctx, conversationID, seq)
|
||||||
|
// if err != nil {
|
||||||
|
// log.ZWarn(ctx, "SetNotificationSeq err", err, "conversationID", conversationID, "seq", seq)
|
||||||
|
// continue
|
||||||
|
// } else {
|
||||||
|
// m.syncedMaxSeqs[conversationID] = seq
|
||||||
|
// }
|
||||||
|
//}
|
||||||
for conversationID, maxSeq := range messagesSeqMap {
|
for conversationID, maxSeq := range messagesSeqMap {
|
||||||
if syncedMaxSeq, ok := m.syncedMaxSeqs[conversationID]; ok {
|
if syncedMaxSeq, ok := m.syncedMaxSeqs[conversationID]; ok {
|
||||||
if maxSeq > syncedMaxSeq {
|
if maxSeq > syncedMaxSeq {
|
||||||
@ -217,7 +234,12 @@ func (m *MsgSyncer) pushTriggerAndSync(ctx context.Context, pullMsgs map[string]
|
|||||||
|
|
||||||
// Called after successful reconnection to synchronize the latest message
|
// Called after successful reconnection to synchronize the latest message
|
||||||
func (m *MsgSyncer) doConnected(ctx context.Context) {
|
func (m *MsgSyncer) doConnected(ctx context.Context) {
|
||||||
|
reinstalled := m.reinstalled
|
||||||
|
if reinstalled {
|
||||||
|
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.AppDataSyncStart}, m.conversationCh)
|
||||||
|
} else {
|
||||||
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.MsgSyncBegin}, m.conversationCh)
|
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.MsgSyncBegin}, m.conversationCh)
|
||||||
|
}
|
||||||
var resp sdkws.GetMaxSeqResp
|
var resp sdkws.GetMaxSeqResp
|
||||||
if err := m.longConnMgr.SendReqWaitResp(m.ctx, &sdkws.GetMaxSeqReq{UserID: m.loginUserID}, constant.GetNewestSeq, &resp); err != nil {
|
if err := m.longConnMgr.SendReqWaitResp(m.ctx, &sdkws.GetMaxSeqReq{UserID: m.loginUserID}, constant.GetNewestSeq, &resp); err != nil {
|
||||||
log.ZError(m.ctx, "get max seq error", err)
|
log.ZError(m.ctx, "get max seq error", err)
|
||||||
@ -227,7 +249,11 @@ func (m *MsgSyncer) doConnected(ctx context.Context) {
|
|||||||
log.ZDebug(m.ctx, "get max seq success", "resp", resp)
|
log.ZDebug(m.ctx, "get max seq success", "resp", resp)
|
||||||
}
|
}
|
||||||
m.compareSeqsAndBatchSync(ctx, resp.MaxSeqs, connectPullNums)
|
m.compareSeqsAndBatchSync(ctx, resp.MaxSeqs, connectPullNums)
|
||||||
|
if reinstalled {
|
||||||
|
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.AppDataSyncFinish}, m.conversationCh)
|
||||||
|
} else {
|
||||||
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.MsgSyncEnd}, m.conversationCh)
|
common.TriggerCmdNotification(m.ctx, sdk_struct.CmdNewMsgComeToConversation{SyncFlag: constant.MsgSyncEnd}, m.conversationCh)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsNotification(conversationID string) bool {
|
func IsNotification(conversationID string) bool {
|
||||||
@ -363,24 +389,24 @@ func (m *MsgSyncer) syncMsgBySeqs(ctx context.Context, conversationID string, se
|
|||||||
|
|
||||||
// triggers a conversation with a new message.
|
// triggers a conversation with a new message.
|
||||||
func (m *MsgSyncer) triggerConversation(ctx context.Context, msgs map[string]*sdkws.PullMsgs) error {
|
func (m *MsgSyncer) triggerConversation(ctx context.Context, msgs map[string]*sdkws.PullMsgs) error {
|
||||||
if len(msgs) >= 0 {
|
if len(msgs) > 0 {
|
||||||
err := common.TriggerCmdNewMsgCome(ctx, sdk_struct.CmdNewMsgComeToConversation{Msgs: msgs}, m.conversationCh)
|
err := common.TriggerCmdNewMsgCome(ctx, sdk_struct.CmdNewMsgComeToConversation{Msgs: msgs}, m.conversationCh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "triggerCmdNewMsgCome err", err, "msgs", msgs)
|
log.ZError(ctx, "triggerCmdNewMsgCome err", err, "msgs", msgs)
|
||||||
}
|
}
|
||||||
log.ZDebug(ctx, "triggerConversation", "msgs", msgs)
|
log.ZDebug(ctx, "triggerConversation", "msgs", msgs)
|
||||||
return err
|
return err
|
||||||
|
} else {
|
||||||
|
log.ZDebug(ctx, "triggerConversation is nil", "msgs", msgs)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MsgSyncer) triggerNotification(ctx context.Context, msgs map[string]*sdkws.PullMsgs) error {
|
func (m *MsgSyncer) triggerNotification(ctx context.Context, msgs map[string]*sdkws.PullMsgs) error {
|
||||||
if len(msgs) >= 0 {
|
if len(msgs) > 0 {
|
||||||
err := common.TriggerCmdNotification(ctx, sdk_struct.CmdNewMsgComeToConversation{Msgs: msgs}, m.conversationCh)
|
common.TriggerCmdNotification(ctx, sdk_struct.CmdNewMsgComeToConversation{Msgs: msgs}, m.conversationCh)
|
||||||
if err != nil {
|
} else {
|
||||||
log.ZError(ctx, "triggerCmdNewMsgCome err", err, "msgs", msgs)
|
log.ZDebug(ctx, "triggerNotification is nil", "msgs", msgs)
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
|
@ -22,10 +22,9 @@ import (
|
|||||||
"github.com/openimsdk/openim-sdk-core/v3/pkg/db/model_struct"
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/db/model_struct"
|
||||||
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
|
||||||
userPb "github.com/openimsdk/protocol/user"
|
userPb "github.com/openimsdk/protocol/user"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
|
||||||
|
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,6 +44,22 @@ func (u *User) SyncLoginUserInfo(ctx context.Context) error {
|
|||||||
log.ZDebug(ctx, "SyncLoginUserInfo", "remoteUser", remoteUser, "localUser", localUser)
|
log.ZDebug(ctx, "SyncLoginUserInfo", "remoteUser", remoteUser, "localUser", localUser)
|
||||||
return u.userSyncer.Sync(ctx, []*model_struct.LocalUser{remoteUser}, localUsers, nil)
|
return u.userSyncer.Sync(ctx, []*model_struct.LocalUser{remoteUser}, localUsers, nil)
|
||||||
}
|
}
|
||||||
|
func (u *User) SyncLoginUserInfoWithoutNotice(ctx context.Context) error {
|
||||||
|
remoteUser, err := u.GetSingleUserFromSvr(ctx, u.loginUserID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localUser, err := u.GetLoginUser(ctx, u.loginUserID)
|
||||||
|
if err != nil && errs.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||||
|
log.ZError(ctx, "SyncLoginUserInfo", err)
|
||||||
|
}
|
||||||
|
var localUsers []*model_struct.LocalUser
|
||||||
|
if err == nil {
|
||||||
|
localUsers = []*model_struct.LocalUser{localUser}
|
||||||
|
}
|
||||||
|
log.ZDebug(ctx, "SyncLoginUserInfo", "remoteUser", remoteUser, "localUser", localUser)
|
||||||
|
return u.userSyncer.Sync(ctx, []*model_struct.LocalUser{remoteUser}, localUsers, nil, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) SyncUserStatus(ctx context.Context, fromUserID string, status int32, platformID int32) {
|
func (u *User) SyncUserStatus(ctx context.Context, fromUserID string, status int32, platformID int32) {
|
||||||
userOnlineStatus := userPb.OnlineStatus{
|
userOnlineStatus := userPb.OnlineStatus{
|
||||||
@ -95,3 +110,19 @@ func (u *User) SyncAllCommand(ctx context.Context) error {
|
|||||||
log.ZDebug(ctx, "sync command", "data from server", serverData, "data from local", localData)
|
log.ZDebug(ctx, "sync command", "data from server", serverData, "data from local", localData)
|
||||||
return u.commandSyncer.Sync(ctx, datautil.Batch(ServerCommandToLocalCommand, serverData.CommandResp), localData, nil)
|
return u.commandSyncer.Sync(ctx, datautil.Batch(ServerCommandToLocalCommand, serverData.CommandResp), localData, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) SyncAllCommandWithoutNotice(ctx context.Context) error {
|
||||||
|
var serverData CommandInfoResponse
|
||||||
|
err := util.ApiPost(ctx, constant.ProcessUserCommandGetAll, userPb.ProcessUserCommandGetAllReq{
|
||||||
|
UserID: u.loginUserID,
|
||||||
|
}, &serverData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
localData, err := u.DataBase.ProcessUserCommandGetAll(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.ZDebug(ctx, "sync command", "data from server", serverData, "data from local", localData)
|
||||||
|
return u.commandSyncer.Sync(ctx, datautil.Batch(ServerCommandToLocalCommand, serverData.CommandResp), localData, nil, false, true)
|
||||||
|
}
|
||||||
|
@ -142,17 +142,21 @@ func newEmptyConversationListener(ctx context.Context) open_im_sdk_callback.OnCo
|
|||||||
return &emptyConversationListener{ctx: ctx}
|
return &emptyConversationListener{ctx: ctx}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *emptyConversationListener) OnSyncServerStart() {
|
func (e *emptyConversationListener) OnSyncServerStart(reinstalled bool) {
|
||||||
|
|
||||||
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *emptyConversationListener) OnSyncServerFinish() {
|
func (e *emptyConversationListener) OnSyncServerProgress(progress int) {
|
||||||
|
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil,
|
||||||
|
"progress", progress)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *emptyConversationListener) OnSyncServerFinish(reinstalled bool) {
|
||||||
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *emptyConversationListener) OnSyncServerFailed() {
|
func (e *emptyConversationListener) OnSyncServerFailed(reinstalled bool) {
|
||||||
|
|
||||||
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
log.ZWarn(e.ctx, "ConversationListener is not implemented", nil)
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,10 @@ type OnFriendshipListener interface {
|
|||||||
OnBlackDeleted(blackInfo string)
|
OnBlackDeleted(blackInfo string)
|
||||||
}
|
}
|
||||||
type OnConversationListener interface {
|
type OnConversationListener interface {
|
||||||
OnSyncServerStart()
|
OnSyncServerStart(reinstalled bool)
|
||||||
OnSyncServerFinish()
|
OnSyncServerFinish(reinstalled bool)
|
||||||
//OnSyncServerProgress(progress int)
|
OnSyncServerProgress(progress int)
|
||||||
OnSyncServerFailed()
|
OnSyncServerFailed(reinstalled bool)
|
||||||
OnNewConversation(conversationList string)
|
OnNewConversation(conversationList string)
|
||||||
OnConversationChanged(conversationList string)
|
OnConversationChanged(conversationList string)
|
||||||
OnTotalUnreadMessageCountChanged(totalUnreadCount int32)
|
OnTotalUnreadMessageCountChanged(totalUnreadCount int32)
|
||||||
|
@ -44,22 +44,12 @@ func TriggerCmdNewMsgCome(ctx context.Context, msg sdk_struct.CmdNewMsgComeToCon
|
|||||||
return sendCmd(conversationCh, c2v, 100)
|
return sendCmd(conversationCh, c2v, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TriggerCmdSuperGroupMsgCome(msg sdk_struct.CmdNewMsgComeToConversation, conversationCh chan Cmd2Value) error {
|
func TriggerCmdNotification(ctx context.Context, msg sdk_struct.CmdNewMsgComeToConversation, conversationCh chan Cmd2Value) {
|
||||||
if conversationCh == nil {
|
|
||||||
return utils.Wrap(errors.New("ch == nil"), "")
|
|
||||||
}
|
|
||||||
|
|
||||||
c2v := Cmd2Value{Cmd: constant.CmdSuperGroupMsgCome, Value: msg}
|
|
||||||
return sendCmd(conversationCh, c2v, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TriggerCmdNotification(ctx context.Context, msg sdk_struct.CmdNewMsgComeToConversation, conversationCh chan Cmd2Value) error {
|
|
||||||
if conversationCh == nil {
|
|
||||||
return utils.Wrap(errors.New("ch == nil"), "")
|
|
||||||
}
|
|
||||||
|
|
||||||
c2v := Cmd2Value{Cmd: constant.CmdNotification, Value: msg, Ctx: ctx}
|
c2v := Cmd2Value{Cmd: constant.CmdNotification, Value: msg, Ctx: ctx}
|
||||||
return sendCmd(conversationCh, c2v, 100)
|
err := sendCmd(conversationCh, c2v, 100)
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, "TriggerCmdNotification error", err, "msg", msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TriggerCmdWakeUp(ch chan Cmd2Value) error {
|
func TriggerCmdWakeUp(ch chan Cmd2Value) error {
|
||||||
|
@ -403,6 +403,8 @@ const (
|
|||||||
MsgSyncProcessing = 1002 //
|
MsgSyncProcessing = 1002 //
|
||||||
MsgSyncEnd = 1003 //
|
MsgSyncEnd = 1003 //
|
||||||
MsgSyncFailed = 1004
|
MsgSyncFailed = 1004
|
||||||
|
AppDataSyncStart = 1005
|
||||||
|
AppDataSyncFinish = 1006
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -173,6 +173,7 @@ type MessageModel interface {
|
|||||||
DeleteConversationMsgs(ctx context.Context, conversationID string, msgIDs []string) error
|
DeleteConversationMsgs(ctx context.Context, conversationID string, msgIDs []string) error
|
||||||
// DeleteConversationMsgsBySeqs(ctx context.Context, conversationID string, seqs []int64) error
|
// DeleteConversationMsgsBySeqs(ctx context.Context, conversationID string, seqs []int64) error
|
||||||
SetNotificationSeq(ctx context.Context, conversationID string, seq int64) error
|
SetNotificationSeq(ctx context.Context, conversationID string, seq int64) error
|
||||||
|
BatchInsertNotificationSeq(ctx context.Context, notificationSeqs []*model_struct.NotificationSeqs) error
|
||||||
GetNotificationAllSeqs(ctx context.Context) ([]*model_struct.NotificationSeqs, error)
|
GetNotificationAllSeqs(ctx context.Context) ([]*model_struct.NotificationSeqs, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/openimsdk/openim-sdk-core/v3/pkg/db/model_struct"
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/db/model_struct"
|
||||||
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
|
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
|
||||||
|
"github.com/openimsdk/tools/errs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DataBase) SetNotificationSeq(ctx context.Context, conversationID string, seq int64) error {
|
func (d *DataBase) SetNotificationSeq(ctx context.Context, conversationID string, seq int64) error {
|
||||||
@ -36,6 +37,12 @@ func (d *DataBase) SetNotificationSeq(ctx context.Context, conversationID string
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBase) BatchInsertNotificationSeq(ctx context.Context, notificationSeqs []*model_struct.NotificationSeqs) error {
|
||||||
|
d.mRWMutex.Lock()
|
||||||
|
defer d.mRWMutex.Unlock()
|
||||||
|
return errs.WrapMsg(d.conn.WithContext(ctx).Create(notificationSeqs).Error, "BatchInsertNotificationSeq failed")
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DataBase) GetNotificationAllSeqs(ctx context.Context) ([]*model_struct.NotificationSeqs, error) {
|
func (d *DataBase) GetNotificationAllSeqs(ctx context.Context) ([]*model_struct.NotificationSeqs, error) {
|
||||||
d.mRWMutex.Lock()
|
d.mRWMutex.Lock()
|
||||||
defer d.mRWMutex.Unlock()
|
defer d.mRWMutex.Unlock()
|
||||||
|
@ -653,16 +653,16 @@ func (c *conversationCallBack) OnSyncServerProgress(progress int) {
|
|||||||
log.ZInfo(ctx, utils.GetSelfFuncName(), "progress", progress)
|
log.ZInfo(ctx, utils.GetSelfFuncName(), "progress", progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationCallBack) OnSyncServerStart() {
|
func (c *conversationCallBack) OnSyncServerStart(reinstalled bool) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationCallBack) OnSyncServerFinish() {
|
func (c *conversationCallBack) OnSyncServerFinish(reinstalled bool) {
|
||||||
c.SyncFlag = 1
|
c.SyncFlag = 1
|
||||||
log.ZInfo(ctx, utils.GetSelfFuncName())
|
log.ZInfo(ctx, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationCallBack) OnSyncServerFailed() {
|
func (c *conversationCallBack) OnSyncServerFailed(reinstalled bool) {
|
||||||
log.ZInfo(ctx, utils.GetSelfFuncName())
|
log.ZInfo(ctx, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
go/export.go
24
go/export.go
@ -77,16 +77,28 @@ func NewConversationCallback(cCallback C.CB_I_S) *ConversationCallback {
|
|||||||
return &ConversationCallback{cCallback: cCallback}
|
return &ConversationCallback{cCallback: cCallback}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationCallback) OnSyncServerStart() {
|
func (c ConversationCallback) OnSyncServerStart(reinstalled bool) {
|
||||||
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_START, NO_DATA)
|
m := make(map[string]any)
|
||||||
|
m["reinstalled"] = reinstalled
|
||||||
|
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_START, C.CString(StructToJsonString(m)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationCallback) OnSyncServerFinish() {
|
func (c ConversationCallback) OnSyncServerProgress(progress int) {
|
||||||
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_FINISH, NO_DATA)
|
m := make(map[string]any)
|
||||||
|
m["progress"] = progress
|
||||||
|
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_PROGRESS, C.CString(StructToJsonString(m)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationCallback) OnSyncServerFailed() {
|
func (c ConversationCallback) OnSyncServerFinish(reinstalled bool) {
|
||||||
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_FAILED, NO_DATA)
|
m := make(map[string]any)
|
||||||
|
m["reinstalled"] = reinstalled
|
||||||
|
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_FINISH, C.CString(StructToJsonString(m)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ConversationCallback) OnSyncServerFailed(reinstalled bool) {
|
||||||
|
m := make(map[string]any)
|
||||||
|
m["reinstalled"] = reinstalled
|
||||||
|
C.Call_CB_I_S(c.cCallback, SYNC_SERVER_FAILED, C.CString(StructToJsonString(m)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationCallback) OnNewConversation(conversationList string) {
|
func (c ConversationCallback) OnNewConversation(conversationList string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user