diff --git a/handlers/socket.go b/handlers/socket.go index 8ff3330..b6db557 100644 --- a/handlers/socket.go +++ b/handlers/socket.go @@ -44,15 +44,15 @@ func WebsocketConnection(c *websocket.Conn) { } func GetConnectedSockets(c *fiber.Ctx) error { - jabber := map[string]socket.Socket[socket.JabberData]{} + jabber := aid.JSON{} socket.JabberSockets.Range(func(key string, value *socket.Socket[socket.JabberData]) bool { - jabber[key] = *value + jabber[key] = value return true }) - matchmaking := []socket.Socket[socket.MatchmakerData]{} + matchmaking := aid.JSON{} socket.MatchmakerSockets.Range(func(key string, value *socket.Socket[socket.MatchmakerData]) bool { - matchmaking = append(matchmaking, *value) + matchmaking[key] = value return true }) diff --git a/readme.md b/readme.md index 1430486..f09336e 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ Performance first, universal Fortnite private server backend written in Go. - Gifting, Matchmaker and Battle Pass support. - Interact with external Services like Amazon S3 Buckets to save player data externally. -- A way to interact with accounts outside of the game. This is mainly for a web app and other services to interact with the backend. +- Refactor the XMPP solution to use [melium/xmpp](https://github.com/mellium/xmpp) ## Version Support diff --git a/socket/socket.go b/socket/socket.go index 99e6628..a97b1ee 100644 --- a/socket/socket.go +++ b/socket/socket.go @@ -19,12 +19,12 @@ type Socket[T JabberData | MatchmakerData] struct { Connection *websocket.Conn Data *T Person *person.Person - mutex sync.Mutex + M sync.Mutex } func (s *Socket[T]) Write(payload []byte) { - s.mutex.Lock() - defer s.mutex.Unlock() + s.M.Lock() + defer s.M.Unlock() s.Connection.WriteMessage(websocket.TextMessage, payload) }