本文整理汇总了Python中twisted.internet.protocol.ServerFactory.publisher方法的典型用法代码示例。如果您正苦于以下问题:Python ServerFactory.publisher方法的具体用法?Python ServerFactory.publisher怎么用?Python ServerFactory.publisher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.ServerFactory
的用法示例。
在下文中一共展示了ServerFactory.publisher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeService
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import publisher [as 别名]
def makeService(options):
# primary setup
application = service.Application(meta.display_name)
services = service.IServiceCollection(application)
# setup message server
serverFactory = ServerFactory()
serverFactory.protocol = Listener
serverFactory.publisher = PublisherFactory()
msgServer = internet.TCPServer(config.listener.port, serverFactory)
msgServer.setName(config.listener.servicename)
msgServer.setServiceParent(services)
# setup IRC message client
if config.irc.sslEnabled:
msgService = internet.SSLClient(config.irc.server, config.irc.port,
serverFactory.publisher, ClientContextFactory())
else:
msgService = internet.TCPClient(config.irc.server, config.irc.port,
serverFactory.publisher)
msgService.setName(config.irc.servicename)
msgService.setServiceParent(services)
# setup IRC log client
logger = LoggerFactory(config.irc.server, config.log.channels)
logService = internet.TCPClient(config.irc.server, config.irc.port,
logger)
logService.setName(config.log.servicename)
logService.setServiceParent(services)
# setuplog rotator
rotService = internet.TimerService(config.log.rotate.checkInterval,
logger.rotateLogs, logService)
rotService.setName(config.log.rotate.servicename)
rotService.setServiceParent(services)
# setup log file web server
webroot = static.File(config.log.http.docRoot)
if config.log.http.vhostEnabled:
vResource = vhost.VHostMonsterResource()
webroot.putChild('vhost', vResource)
if config.log.http.auth == 'basic':
guarded = auth.guardResourceWithBasicAuth(
webroot, config.log.http.realm, config.log.http.users)
site = server.Site(guarded)
else:
site = server.Site(webroot)
webserver = internet.TCPServer(config.log.http.port, site)
webserver.setName(config.log.http.servicename)
webserver.setServiceParent(services)
# setup ssh access to a Python shell
interpreterType = carapace_const.PYTHON
sshFactory = getShellFactory(
interpreterType, app=application, services=services)
sshserver = internet.TCPServer(config.ssh.port, sshFactory)
sshserver.setName(config.ssh.servicename)
sshserver.setServiceParent(services)
return services