More socket
This commit is contained in:
parent
6c02bfd014
commit
85383e4865
|
@ -44,15 +44,15 @@ func WebsocketConnection(c *websocket.Conn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConnectedSockets(c *fiber.Ctx) error {
|
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 {
|
socket.JabberSockets.Range(func(key string, value *socket.Socket[socket.JabberData]) bool {
|
||||||
jabber[key] = *value
|
jabber[key] = value
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
matchmaking := []socket.Socket[socket.MatchmakerData]{}
|
matchmaking := aid.JSON{}
|
||||||
socket.MatchmakerSockets.Range(func(key string, value *socket.Socket[socket.MatchmakerData]) bool {
|
socket.MatchmakerSockets.Range(func(key string, value *socket.Socket[socket.MatchmakerData]) bool {
|
||||||
matchmaking = append(matchmaking, *value)
|
matchmaking[key] = value
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ Performance first, universal Fortnite private server backend written in Go.
|
||||||
|
|
||||||
- Gifting, Matchmaker and Battle Pass support.
|
- Gifting, Matchmaker and Battle Pass support.
|
||||||
- Interact with external Services like Amazon S3 Buckets to save player data externally.
|
- 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
|
## Version Support
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,12 @@ type Socket[T JabberData | MatchmakerData] struct {
|
||||||
Connection *websocket.Conn
|
Connection *websocket.Conn
|
||||||
Data *T
|
Data *T
|
||||||
Person *person.Person
|
Person *person.Person
|
||||||
mutex sync.Mutex
|
M sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Socket[T]) Write(payload []byte) {
|
func (s *Socket[T]) Write(payload []byte) {
|
||||||
s.mutex.Lock()
|
s.M.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.M.Unlock()
|
||||||
|
|
||||||
s.Connection.WriteMessage(websocket.TextMessage, payload)
|
s.Connection.WriteMessage(websocket.TextMessage, payload)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user