Browse Source

补充上session_id

luoyangwei 1 year ago
parent
commit
7bb6492108
3 changed files with 2 additions and 1 deletions
  1. 1 0
      server/client.go
  2. 0 1
      server/hub.go
  3. 1 0
      server/message.go

+ 1 - 0
server/client.go

@@ -330,6 +330,7 @@ func (c *Client) procNotify(ctx context.Context, notificationContent Notificatio
 // procChating received message processing
 func (c *Client) procChating(ctx context.Context, msgType MessageType, chatingContent ChatingContent) {
 	requestId := ctx.Value("request_id").(string)
+	chatingContent.SessionId = chatingContent.Receiver
 
 	// Receiver ID format determines whether the receiver is an account or a session
 	users := c.regexpReceiveUserIds(chatingContent.Receiver)

+ 0 - 1
server/hub.go

@@ -61,7 +61,6 @@ func (h *Hub) run() {
 			}
 		case message := <-h.Message:
 			h.mutex.RLock()
-			// zap.L().Info("message: ", zap.Any("message", message))
 			if client, ok := h.clients[message.Receiver]; ok {
 				zap.L().Info("[conn] message to client",
 					zap.String("receiver", message.Receiver),

+ 1 - 0
server/message.go

@@ -64,6 +64,7 @@ type (
 	ChatingContent struct {
 		MessageId   string             `json:"messageId" mapstructure:"messageId"`
 		Receiver    string             `json:"receiver" mapstructure:"receiver"`
+		SessionId   string             `json:"sessionId" mapstructure:"sessionId"` // SessionId 过度字段, 一般和 Receiver 内容相同
 		PayloadType ChatingContentType `json:"payloadType" mapstructure:"payloadType"`
 		Payload     any                `json:"payload" mapstructure:"payload"`
 		SendTime    int64              `json:"sendTime" mapstructure:"sendTime"`