2 Simple Client Counter for VLC VLM
8 class ClientCounter(object):
12 self._lock = gevent.coros.RLock()
16 return self.clients.get(id, (False,))[0]
18 def add(self, id, ip, unic):
20 logger = logging.getLogger('clientcounter_Add')
21 if self.clients.has_key(id):
22 self.clients[id][0] += 1
23 self.clients[id][1].append([ip,unic])
24 logger.info('counter for %s incremented to %s' % (id,self.clients[id][0]))
26 self.clients[id] = [1, [[ip,unic]]]
27 logger.info('counter for %s started (1)' % id)
30 logger.info('total count = %s' % self.total)
33 return self.clients[id][0]
35 def delete(self, id, ip, unic):
37 logger = logging.getLogger('clientcounter_Del')
38 if self.clients.has_key(id):
40 logger.info('total count = %s' % self.total)
41 if self.clients[id][0] == 1:
43 logger.info('counter for %s decremented to zero' % id )
47 self.clients[id][0] -= 1
48 self.clients[id][1].remove([ip,unic])
49 logger.info('counter for %s decremented to %s' % (id,self.clients[id][0]))
55 return self.clients[id][0]