use uuid in connection, message. Add fetch connections function

This commit is contained in:
2026-04-07 20:06:06 +02:00
parent 9b57157769
commit 26fef0a777
4 changed files with 47 additions and 22 deletions
+8 -5
View File
@@ -4,6 +4,7 @@ import (
"time"
"github.com/coder/websocket"
"github.com/google/uuid"
)
type User struct {
@@ -14,23 +15,25 @@ type User struct {
WsConn *websocket.Conn
Id uint32
Groups map[uint32]struct{}
Connections map[uint32]*Connection
Connections map[uuid.UUID]*Connection
Color [3]uint8
}
type Connection struct {
Id uuid.UUID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
MessagesBuf [MaxDirectMsgCache]*Message `json:"-"`
Id uint32 `json:"id"`
RequestorId uint32 `json:"requestorId"`
RecipientId uint32 `json:"recipientId"`
State uint8 `json:"state"`
}
type Message struct {
Content string `json:"content"`
CreatedAt time.Time `json:"createdAt"`
Sender uint32 `json:"sender"`
Id uuid.UUID `json:"id"`
Content string `json:"content"`
CreatedAt time.Time `json:"createdAt"`
Sender uint32 `json:"sender"`
IsGroupMessage bool `json:"isGroupMessage"`
}
type Group struct {