|
@@ -74,7 +74,7 @@ func (c *Client) Reader() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// writer is event listening for servers sending messages to clients
|
|
|
+// Writer is event listening for servers sending messages to clients
|
|
|
func (c *Client) Writer() {
|
|
|
ticker := time.NewTicker(c.pingpongWait)
|
|
|
defer func() {
|
|
@@ -219,11 +219,8 @@ func (c *Client) persistenceMessage(ctx context.Context, message *Message) error
|
|
|
ID: message.MessageId,
|
|
|
Receiver: message.Receiver,
|
|
|
Sender: message.sender,
|
|
|
- Type: message.Type,
|
|
|
- ContentType: 1,
|
|
|
+ PayloadType: 1,
|
|
|
SentAt: time.Now().UTC(),
|
|
|
- // IsRead: false,
|
|
|
- // Received: false,
|
|
|
}
|
|
|
|
|
|
zap.L().Info("[persistence] save database begin",
|
|
@@ -241,9 +238,10 @@ func (c *Client) persistenceMessage(ctx context.Context, message *Message) error
|
|
|
case MessageTypeUpChating:
|
|
|
// Chat dialogue messages
|
|
|
chatingContent := message.Content.(ChatingContent)
|
|
|
- chatingContent.MessageId = message.MessageId // Important, not having this line may result in the inability to receive messages
|
|
|
- mod.ContentType = uint8(chatingContent.PayloadType) // Important, not having this line may result in the inability to receive messages
|
|
|
+ chatingContent.MessageId = message.MessageId // Important, not having this line may result in the inability to receive messages
|
|
|
+ mod.PayloadType = chatingContent.PayloadType // Important, not having this line may result in the inability to receive messages
|
|
|
mod.Receiver = chatingContent.Receiver
|
|
|
+ mod.SessionId = chatingContent.SessionId
|
|
|
|
|
|
// Format the structure. Sometimes,
|
|
|
// the data passed in may contain fields that contaminate the structure.
|
|
@@ -266,7 +264,7 @@ func (c *Client) persistenceMessage(ctx context.Context, message *Message) error
|
|
|
}
|
|
|
payload, _ := json.Marshal(chatingContent.Payload)
|
|
|
|
|
|
- mod.Content = payload
|
|
|
+ mod.Payload = payload
|
|
|
mod.SentAt = time.UnixMilli(chatingContent.SendTime)
|
|
|
message.Content = chatingContent
|
|
|
// case MessageTypeNotification:
|