mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 18:15:59 +08:00
change send message by ws and optimization
This commit is contained in:
@@ -3,15 +3,20 @@ package logic
|
||||
import (
|
||||
"Open_IM/src/common/db"
|
||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/src/common/log"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
)
|
||||
|
||||
func saveUserChat(uid string, pbMsg *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
||||
time := utils.GetCurrentTimestampByMill()
|
||||
seq, err := db.DB.IncrUserSeq(uid)
|
||||
if err != nil {
|
||||
log.NewError(pbMsg.OperationID, "data insert to redis err", err.Error(), pbMsg.String())
|
||||
return err
|
||||
}
|
||||
pbMsg.RecvSeq = seq
|
||||
log.NewInfo(pbMsg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
||||
return db.DB.SaveUserChat(uid, pbMsg.SendTime, pbMsg)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ func (mc *HistoryConsumerHandler) Init() {
|
||||
|
||||
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
||||
log.InfoByKv("chat come mongo!!!", "", "chat", string(msg))
|
||||
time := utils.GetCurrentTimestampBySecond()
|
||||
pbData := pbMsg.WSToMsgSvrChatMsg{}
|
||||
err := proto.Unmarshal(msg, &pbData)
|
||||
if err != nil {
|
||||
@@ -78,11 +79,13 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
|
||||
//}
|
||||
}
|
||||
|
||||
log.NewInfo(pbSaveData.OperationID, "saveUserChat cost time ", utils.GetCurrentTimestampBySecond()-time)
|
||||
}
|
||||
if msgKey == pbSaveData.RecvID {
|
||||
pbSaveData.Options = pbData.Options
|
||||
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
||||
sendMessageToPush(&pbSaveData)
|
||||
log.NewInfo(pbSaveData.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampBySecond()-time)
|
||||
}
|
||||
|
||||
log.InfoByKv("msg_transfer handle topic success...", "", "")
|
||||
|
||||
@@ -20,6 +20,6 @@ func Init() {
|
||||
}
|
||||
func Run() {
|
||||
//register mysqlConsumerHandler to
|
||||
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||
//go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user