Skip to content

Commit

Permalink
CTX wasn't pulling the right connection reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Syleron committed Jan 25, 2021
1 parent d455b0f commit 18500a1
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions sockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 18500a1

Please sign in to comment.