Browse Source

fixing player list not working when multiple servers in different installations have the same server ID

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
bf5a5972c6
  1. 16
      pyweb/mumble/mmobjects.py
  2. 2
      pyweb/mumble/models.py

16
pyweb/mumble/mmobjects.py

@ -30,16 +30,17 @@ class mmServer( object ):
# id = int(); # id = int();
# rootName = str(); # rootName = str();
def __init__( self, serverID, ctl, rootName = '' ):
def __init__( self, model, ctl ):
#self.dbusObj = serverObj; #self.dbusObj = serverObj;
self.channels = dict(); self.channels = dict();
self.players = dict(); self.players = dict();
self.id = serverID;
self.rootName = rootName;
self.id = model.srvid;
self.rootName = model.name;
self.model = model;
links = dict(); links = dict();
for theChan in ctl.getChannels(serverID):
for theChan in ctl.getChannels(model.srvid):
# Channels - Fields: 0 = ID, 1 = Name, 2 = Parent-ID, 3 = Links # Channels - Fields: 0 = ID, 1 = Name, 2 = Parent-ID, 3 = Links
if( theChan[2] == -1 ): if( theChan[2] == -1 ):
@ -68,10 +69,10 @@ class mmServer( object ):
if self.rootName: if self.rootName:
self.channels[0].name = self.rootName; self.channels[0].name = self.rootName;
for thePlayer in ctl.getPlayers(serverID):
for thePlayer in ctl.getPlayers(model.srvid):
# in DBus # in DBus
# Players - Fields: 0 = UserID, 6 = ChannelID # Players - Fields: 0 = UserID, 6 = ChannelID
self.players[ thePlayer[0] ] = mmPlayer( thePlayer, self.channels[ thePlayer[6] ] );
self.players[ thePlayer[0] ] = mmPlayer( self.model, thePlayer, self.channels[ thePlayer[6] ] );
playerCount = property( playerCount = property(
@ -166,7 +167,7 @@ class mmPlayer( object ):
# mumbleuser = models.MumbleUser(); # mumbleuser = models.MumbleUser();
def __init__( self, playerObj, playerChan ):
def __init__( self, srvInstance, playerObj, playerChan ):
( self.userid, self.muted, self.deafened, self.suppressed, self.selfmuted, self.selfdeafened, chanID, self.dbaseid, self.name, onlinetime, self.bytesPerSec ) = playerObj; ( self.userid, self.muted, self.deafened, self.suppressed, self.selfmuted, self.selfdeafened, chanID, self.dbaseid, self.name, onlinetime, self.bytesPerSec ) = playerObj;
self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) ); self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) );
self.channel = playerChan; self.channel = playerChan;
@ -174,7 +175,6 @@ class mmPlayer( object ):
if self.isAuthed(): if self.isAuthed():
from models import Mumble, MumbleUser from models import Mumble, MumbleUser
srvInstance = Mumble.objects.get( srvid=self.channel.serverId );
try: try:
self.mumbleuser = MumbleUser.objects.get( mumbleid=self.dbaseid, server=srvInstance ); self.mumbleuser = MumbleUser.objects.get( mumbleid=self.dbaseid, server=srvInstance );
except MumbleUser.DoesNotExist: except MumbleUser.DoesNotExist:

2
pyweb/mumble/models.py

@ -50,7 +50,7 @@ class Mumble( models.Model ):
booted = models.BooleanField( 'Boot Server', default = True ); booted = models.BooleanField( 'Boot Server', default = True );
def getServerObject( self ): def getServerObject( self ):
return mmServer( self.srvid, MumbleCtlBase.newInstance( self.dbus ), self.name );
return mmServer( self, MumbleCtlBase.newInstance( self.dbus ) );
def __unicode__( self ): def __unicode__( self ):
return u'Murmur "%s" (%d)' % ( self.name, self.srvid ); return u'Murmur "%s" (%d)' % ( self.name, self.srvid );

Loading…
Cancel
Save