service.MultiService.__init__(self)
self.introducer_url = None
self._announcements = set()
- self._subscribers = {}
+ self._subscribers = {} # dict of (rref->timestamp) dicts
def log(self, *args, **kwargs):
if "facility" not in kwargs:
self.log("introducer: subscription[%s] request at %s" % (service_name,
subscriber))
if service_name not in self._subscribers:
- self._subscribers[service_name] = set()
+ self._subscribers[service_name] = {}
subscribers = self._subscribers[service_name]
if subscriber in subscribers:
self.log("but they're already subscribed, ignoring",
level=log.UNUSUAL)
return
- subscribers.add(subscriber)
+ subscribers[subscriber] = time.time()
def _remove():
self.log("introducer: unsubscribing[%s] %s" % (service_name,
subscriber))
- subscribers.remove(subscriber)
+ subscribers.pop(subscriber, None)
subscriber.notifyOnDisconnect(_remove)
announcements = set( [ a
+import time
from nevow import rend
from foolscap.referenceable import SturdyRef
from twisted.internet import address
# then we actually provide information per subscriber
s = []
for service_name, subscribers in i.get_subscribers().items():
- for rref in subscribers:
+ for (rref, timestamp) in subscribers.items():
sr = rref.getSturdyRef()
nodeid = sr.tubID
ann = clients.get(nodeid)
- s.append( (service_name, rref, ann) )
+ s.append( (service_name, rref, timestamp, ann) )
s.sort()
return s
def render_subscriber_row(self, ctx, s):
- (service_name, rref, ann) = s
+ (service_name, rref, since, ann) = s
nickname = "?"
version = "?"
if ann:
# loopback is a non-IPv4Address
remote_host_s = str(remote_host)
ctx.fillSlots("connected", remote_host_s)
- ctx.fillSlots("since", "?")
+ TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+ ctx.fillSlots("since",
+ time.strftime(TIME_FORMAT, time.localtime(since)))
ctx.fillSlots("version", version)
ctx.fillSlots("service_name", service_name)
return ctx.tag