Browse Source

Add client list sorting in server. Minor changes to client list formatting in crosslink.

wip
Maurizio Porrato 12 years ago
parent
commit
e382cdbc6e
  1. 30
      frn/clienttracker.py
  2. 15
      twisted/plugins/frncrosslink.py

30
frn/clienttracker.py

@ -6,6 +6,29 @@
import shelve
from twisted.python import log
CLIENTS_ORDER = ['Crosslink', 'Parrot', 'Gateway', 'PC Only']
def client_cmp(a, b):
try:
ta = CLIENTS_ORDER.index(a.BC)
except:
ta = CLIENTS_ORDER.index('Gateway')
try:
tb = CLIENTS_ORDER.index(b.BC)
except:
tb = CLIENTS_ORDER.index('Gateway')
if ta < tb:
return -1
elif ta > tb:
return 1
else:
if a.ON < b.ON:
return -1
elif a.ON > b.ON:
return 1
else:
return 0
class ClientTracker(object):
@ -93,7 +116,12 @@ class ClientTracker(object):
self._clientData[clientId] = client
net = client.user.NT
nc = self._net.get(net, [])
nc.append(clientId)
ni = 0
for i, c in enumerate(nc):
if client_cmp(client.user, self._clientData[c]) > 0:
ni = i
break
nc.insert(ni, clientId)
self._net[net] = nc
if clientId in self._mute:
client.user.M = 1

15
twisted/plugins/frncrosslink.py

@ -16,8 +16,7 @@ from twisted.python import log
from os.path import curdir, join as pjoin
cType = {'PC Only': 'O', 'Crosslink': 'C', 'Parrot': 'P'}
cStatus = {'0': 'A', '1': 'N', '2': 'X'}
cMute = {'0': ' ', '1': 'M'}
cStatus = {'0': 'T', '1': 'R', '2': 'N'}
clients = []
talking = None
@ -52,15 +51,17 @@ class FRNCrosslinkClient(FRNClient):
if cmd == "who":
for server, port, u, factory in clients:
cl = []
cl.append("[%s@%s:%d]" % (u.NT,server,port))
cl.append("<u>%s@%s:%d</u>" % (u.NT,server,port))
for c in factory.connection.clients:
cl.append("(%s%s%s %s)" % (
ss = cStatus.get(c['s'], '?')
if c['m'] != '0':
ss = ss.lower()
cl.append(" %s%s %s " % (
cType.get(c['bc'], 'G'),
cStatus.get(c['s'], '?'),
cMute.get(c['m'], '?'),
ss,
c['on'],
))
reply = '<br>'.join(cl)
reply = '<br/>'.join(cl)
self.sendTextMessage(client, reply)
def decodeTX(self, my_id):

Loading…
Cancel
Save