aboutsummaryrefslogtreecommitdiff
path: root/internal/game/session_registry.go
blob: 0e47f829e4208ccd494a6384cb823fed9aa2ef2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package game

import "thehouseoficarus/internal/net"

// attachSession registers a fully-logged-in session in the game's
// character registry. Menu flows call it through connectCharacter; the test
// harness uses it to skip the menu.
func (g *Game) attachSession(sess *net.Session) {
	g.charsMu.Lock()
	g.loggedInChars[sess.Player.Name] = sess
	g.charsMu.Unlock()
}

// detachSession removes a character's registry entry.
func (g *Game) detachSession(name string) {
	g.charsMu.Lock()
	delete(g.loggedInChars, name)
	g.charsMu.Unlock()
}