mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 22:47:16 +02:00
Cleaned up the webclient and changed how it handles sessions and identifies with the server. Fixed some reported bugs caused by the changed layout of sessionhandler.
This commit is contained in:
parent
b1682f78c9
commit
0eb5d29560
16 changed files with 191 additions and 107 deletions
|
|
@ -151,6 +151,14 @@ class SessionHandler(object):
|
|||
num = max(0, num + add)
|
||||
ConfigValue.objects.conf('nr_sessions', str(num))
|
||||
|
||||
def player_count(self):
|
||||
"""
|
||||
Get the number of connected players (not sessions since a player
|
||||
may have more than one session connected if ALLOW_MULTISESSION is True)
|
||||
Only logged-in players are counted here.
|
||||
"""
|
||||
return len(set(sess.uid for sess in self.get_sessions()))
|
||||
|
||||
def sessions_from_player(self, player):
|
||||
"""
|
||||
Given a player, return any matching sessions.
|
||||
|
|
@ -179,6 +187,13 @@ class SessionHandler(object):
|
|||
"""
|
||||
return [sess for sess in self.get_sessions(include_unloggedin=True) if sess.suid and sess.suid == suid]
|
||||
|
||||
def announce_all(self, message):
|
||||
"""
|
||||
Send message to all connected sessions
|
||||
"""
|
||||
for sess in self.get_sessions(include_unloggedin=True):
|
||||
sess.msg(message)
|
||||
|
||||
SESSIONS = SessionHandler()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue