From 18500a10a90927d57702d1b4815358397234dc88 Mon Sep 17 00:00:00 2001 From: Andrew Zak Date: Mon, 25 Jan 2021 12:17:14 +0000 Subject: [PATCH] CTX wasn't pulling the right connection reference --- sockets.go | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/sockets.go b/sockets.go index f5fce28..084dc1b 100644 --- a/sockets.go +++ b/sockets.go @@ -164,36 +164,29 @@ func (s *Sockets) HandleConnection(w http.ResponseWriter, r *http.Request) error var client *Client var uuid string + newConnection := &Connection{ + Conn: ws, + Status: true, + Room: &Room{ + Name: "", + Channel: "", + }, + } + // TODO: Should split this out if s.CheckIfClientExists(jwt.Username) { client = s.Clients[jwt.Username] - uuid = client.addConnection(&Connection{ - Conn: ws, - Status: true, - Room: &Room{ - Name: "", - Channel: "", - }, - }) + uuid = client.addConnection(newConnection) } else { client = &Client{} - uuid = client.addConnection(&Connection{ - Conn: ws, - Status: true, - Room: &Room{ - Name: "", - Channel: "", - }, - }) + uuid = client.addConnection(newConnection) client.Username = jwt.Username s.addClient(client) } // Build our connection context context := &Context{ - Connection: &Connection{ - Conn: ws, - }, + Connection: newConnection, UUID: uuid, Client: client, }