From 85383e4865c26c6f037529785378c43250343734 Mon Sep 17 00:00:00 2001 From: Eccentric Date: Wed, 31 Jan 2024 16:21:19 +0000 Subject: [PATCH] More socket --- handlers/socket.go | 8 ++++---- readme.md | 2 +- socket/socket.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) 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) }