Add client list sorting in server. Minor changes to client list formatting in crosslink.
This commit is contained in:
parent
aad317b0da
commit
e382cdbc6e
|
@ -6,6 +6,29 @@
|
||||||
import shelve
|
import shelve
|
||||||
from twisted.python import log
|
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):
|
class ClientTracker(object):
|
||||||
|
|
||||||
|
@ -93,7 +116,12 @@ class ClientTracker(object):
|
||||||
self._clientData[clientId] = client
|
self._clientData[clientId] = client
|
||||||
net = client.user.NT
|
net = client.user.NT
|
||||||
nc = self._net.get(net, [])
|
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
|
self._net[net] = nc
|
||||||
if clientId in self._mute:
|
if clientId in self._mute:
|
||||||
client.user.M = 1
|
client.user.M = 1
|
||||||
|
|
|
@ -16,8 +16,7 @@ from twisted.python import log
|
||||||
from os.path import curdir, join as pjoin
|
from os.path import curdir, join as pjoin
|
||||||
|
|
||||||
cType = {'PC Only': 'O', 'Crosslink': 'C', 'Parrot': 'P'}
|
cType = {'PC Only': 'O', 'Crosslink': 'C', 'Parrot': 'P'}
|
||||||
cStatus = {'0': 'A', '1': 'N', '2': 'X'}
|
cStatus = {'0': 'T', '1': 'R', '2': 'N'}
|
||||||
cMute = {'0': ' ', '1': 'M'}
|
|
||||||
|
|
||||||
clients = []
|
clients = []
|
||||||
talking = None
|
talking = None
|
||||||
|
@ -52,15 +51,17 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
if cmd == "who":
|
if cmd == "who":
|
||||||
for server, port, u, factory in clients:
|
for server, port, u, factory in clients:
|
||||||
cl = []
|
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:
|
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'),
|
cType.get(c['bc'], 'G'),
|
||||||
cStatus.get(c['s'], '?'),
|
ss,
|
||||||
cMute.get(c['m'], '?'),
|
|
||||||
c['on'],
|
c['on'],
|
||||||
))
|
))
|
||||||
reply = '<br>'.join(cl)
|
reply = '<br/>'.join(cl)
|
||||||
self.sendTextMessage(client, reply)
|
self.sendTextMessage(client, reply)
|
||||||
|
|
||||||
def decodeTX(self, my_id):
|
def decodeTX(self, my_id):
|
||||||
|
|
Loading…
Reference in New Issue