Esempio n. 1
0
class TrackbackHandler:
  def __init__(self, router):
    self.state=YamlMap('config/trackback.yaml')

  def putPeerForEndpoint(self, key, value):
    try:
      map=self.state['endpoints']
      map[key]=value
      self.state.save()
    except:
      pass
Esempio n. 2
0
class TrackbackHandler:
    def __init__(self, router):
        self.state = YamlMap('config/trackback.yaml')

    def putPeerForEndpoint(self, key, value):
        try:
            map = self.state['endpoints']
            map[key] = value
            self.state.save()
        except:
            pass
Esempio n. 3
0
class TrackerHandler:
  def __init__(self, router, addr):
    print('new TrackerHandler '+str(addr))
    self.router=router
    self.addr=addr
    self.state=YamlMap('config/tracker.yaml')

  def getPeerForEndpoint(self, key):
    print('getPeerForEndpoint('+str(key)+')')
    try:
      map=self.state['endpoints']
      value=map[key]
      trackback=TrackbackClient(self.router, self.addr)
      trackback.putPeerForEndpoint(key, value)
    except Exception as e:
      print('exception: '+str(e))
      pass

  def putPeerForEndpoint(self, key, value):
    print('putPeerForEndpoint('+str(key)+','+str(value)+')')
    try:
      map=self.state['endpoints']
      map[key]=value
      self.state.save()
    except Exception as e:
      map={key: value}
      self.state['endpoints']=map

  def getInviteForPeer(self, key):
    print('getInviteForPeer('+str(key)+')')
    try:
      map=self.state['invites']
      value=map[key]
      trackback=TrackbackClient(self.router, self.addr)
      trackback.putInviteForPeer(key, value)
    except Exception as e:
      print('exception: '+str(e))
      pass

  def putInviteForPeer(self, key, value):
    print('putInviteForPeer('+str(key)+','+str(value)+')')
    try:
      map=self.state['invites']
      map[key]=value
      self.state.save()
    except Exception as e:
      map={key: value}
      self.state['invites']=map

  def getTrackerInvite(self):
    invite=self.router.generateInvite()
    trackback=TrackbackClient(self.router, self.addr)
    trackback.putTrackerInvite(encode(invite.message))
Esempio n. 4
0
class TrackerHandler:
    def __init__(self, router, addr):
        print('new TrackerHandler ' + str(addr))
        self.router = router
        self.addr = addr
        self.state = YamlMap('config/tracker.yaml')

    def getPeerForEndpoint(self, key):
        print('getPeerForEndpoint(' + str(key) + ')')
        try:
            map = self.state['endpoints']
            value = map[key]
            trackback = TrackbackClient(self.router, self.addr)
            trackback.putPeerForEndpoint(key, value)
        except Exception as e:
            print('exception: ' + str(e))
            pass

    def putPeerForEndpoint(self, key, value):
        print('putPeerForEndpoint(' + str(key) + ',' + str(value) + ')')
        try:
            map = self.state['endpoints']
            map[key] = value
            self.state.save()
        except Exception as e:
            map = {key: value}
            self.state['endpoints'] = map

    def getInviteForPeer(self, key):
        print('getInviteForPeer(' + str(key) + ')')
        try:
            map = self.state['invites']
            value = map[key]
            trackback = TrackbackClient(self.router, self.addr)
            trackback.putInviteForPeer(key, value)
        except Exception as e:
            print('exception: ' + str(e))
            pass

    def putInviteForPeer(self, key, value):
        print('putInviteForPeer(' + str(key) + ',' + str(value) + ')')
        try:
            map = self.state['invites']
            map[key] = value
            self.state.save()
        except Exception as e:
            map = {key: value}
            self.state['invites'] = map

    def getTrackerInvite(self):
        invite = self.router.generateInvite()
        trackback = TrackbackClient(self.router, self.addr)
        trackback.putTrackerInvite(encode(invite.message))
class TrackbackHandler:
  def __init__(self, keys):
    self.keys=keys
    self.state=YamlMap('config/trackback.yaml')
    self.callbacks={}

  def setPutPeerForEndpointCallback(self, key, callback):
    self.callbacks[key]=callback

  def putPeerForEndpoint(self, key, value):
    print('putPeerForEndpoint!!! '+str(key)+' '+str(value))
    try:
      map=self.state['endpoints']
      map[key]=value
      self.state.save()
    except:
      map={key: value}
      self.state['endpoints']=map
    print('callbacks: '+str(self.callbacks))
    callback=self.callbacks[key]
    callback(key, value)

  def setPutInviteForPeer(self, key, callback):
    self.callbacks[key]=callback

  def putInviteForPeer(self, addr, invite):
    print('putInviteForPeer!!! '+str(addr)+' '+str(invite))
    i=InviteMessage()
    i.decodeInviteMessage(decode(invite))
    self.keys.outgoingInvites.addInvite(i)
    if self.keys.outgoingFilename:
      self.keys.saveOutgoingInvites(self.keys.outgoingFilename, self.keys.invitePassword)

    callback=self.callbacks[addr]
    callback(addr, i)

  def setPutTrackerInvite(self, callback):
    self.callbacks['tracker']=callback

  def putTrackerInvite(self, invite):
    print('putTrackerInvite: '+str(invite))

    callback=self.callbacks['tracker']
    print('callback: '+str(callback))
    callback(decode(invite))
Esempio n. 6
0
class TrackbackHandler:
    def __init__(self, keys):
        self.keys = keys
        self.state = YamlMap("config/trackback.yaml")
        self.callbacks = {}

    def setPutPeerForEndpointCallback(self, key, callback):
        self.callbacks[key] = callback

    def putPeerForEndpoint(self, key, value):
        print("putPeerForEndpoint!!! " + str(key) + " " + str(value))
        try:
            map = self.state["endpoints"]
            map[key] = value
            self.state.save()
        except:
            map = {key: value}
            self.state["endpoints"] = map
        print("callbacks: " + str(self.callbacks))
        callback = self.callbacks[key]
        callback(key, value)

    def setPutInviteForPeer(self, key, callback):
        self.callbacks[key] = callback

    def putInviteForPeer(self, addr, invite):
        print("putInviteForPeer!!! " + str(addr) + " " + str(invite))
        i = InviteMessage()
        i.decodeInviteMessage(decode(invite))
        self.keys.outgoingInvites.addInvite(i)
        if self.keys.outgoingFilename:
            self.keys.saveOutgoingInvites(self.keys.outgoingFilename, self.keys.invitePassword)

        callback = self.callbacks[addr]
        callback(addr, i)

    def setPutTrackerInvite(self, callback):
        self.callbacks["tracker"] = callback

    def putTrackerInvite(self, invite):
        print("putTrackerInvite: " + str(invite))

        callback = self.callbacks["tracker"]
        print("callback: " + str(callback))
        callback(decode(invite))