use uuid in connection, message. Add fetch connections function
This commit is contained in:
+8
-5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user