Ignore:
Timestamp:
Apr 22, 2009, 4:45:04 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@166
Message:

Allow InternalComponent? to host multiple domains.

Author: ralphm.
Fixes #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/component.py

    r41 r54  
    8686    components of this type connect to a router in the same process. This
    8787    allows for one-process XMPP servers.
    88     """
    89 
    90     def __init__(self, router, domain):
     88
     89    @ivar domains: Domains (as C{str}) this component will handle traffic for.
     90    @type domains: L{set}
     91    """
     92
     93    def __init__(self, router, domain=None):
    9194        XMPPHandlerCollection.__init__(self)
    92         self.router = router
    93         self.domain = domain
     95
     96        self._router = router
     97        self.domains = set()
     98        if domain:
     99            self.domains.add(domain)
    94100
    95101        self.xmlstream = None
     
    101107        service.Service.startService(self)
    102108
    103         self.pipe = XmlPipe()
    104         self.xmlstream = self.pipe.source
    105         self.router.addRoute(self.domain, self.pipe.sink)
     109        self._pipe = XmlPipe()
     110        self.xmlstream = self._pipe.source
     111
     112        for domain in self.domains:
     113            self._router.addRoute(domain, self._pipe.sink)
    106114
    107115        for e in self:
     
    116124        service.Service.stopService(self)
    117125
    118         self.router.removeRoute(self.domain, self.pipe.sink)
    119         self.pipe = None
     126        for domain in self.domains:
     127            self._router.removeRoute(domain, self._pipe.sink)
     128
     129        self._pipe = None
    120130        self.xmlstream = None
    121131
Note: See TracChangeset for help on using the changeset viewer.