server: the character and name intents, player names and the roster (#23)
This commit is contained in:
@@ -117,6 +117,19 @@ proc activeCount*(c: Conns): int =
|
||||
withLock c.lock:
|
||||
result = c.active.len
|
||||
|
||||
proc markNamed*(c: Conns, playerId: int) =
|
||||
## `player.setname` succeeded: from now on that player's connections are fed state (6.3). Without
|
||||
## this an unnamed connection would keep receiving nothing but `hello` for ever.
|
||||
withLock c.lock:
|
||||
for i in 0 ..< c.active.len:
|
||||
if c.active[i].playerId == playerId: c.active[i].named = true
|
||||
|
||||
proc connectionsOf*(c: Conns, playerId: int): seq[Conn] =
|
||||
## Every live connection of one player, in activation order (6.1: `hello` + resync to each).
|
||||
withLock c.lock:
|
||||
for conn in c.active:
|
||||
if conn.playerId == playerId: result.add conn
|
||||
|
||||
proc activeCountFor*(c: Conns, playerId: int): int =
|
||||
withLock c.lock:
|
||||
result = c.playerConnIndices(playerId).len
|
||||
|
||||
Reference in New Issue
Block a user