本文整理汇总了Python中autobahn.websocket.WebSocketServerFactory.startFactory方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerFactory.startFactory方法的具体用法?Python WebSocketServerFactory.startFactory怎么用?Python WebSocketServerFactory.startFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.websocket.WebSocketServerFactory
的用法示例。
在下文中一共展示了WebSocketServerFactory.startFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startService
# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import startFactory [as 别名]
def startService(self):
factory = WebSocketServerFactory(u"ws://127.0.0.1:%d" % self.port)
factory.protocol = EchoServerProtocol
# FIXME: Site.start/stopFactory should start/stop factories wrapped as Resources
factory.startFactory()
resource = WebSocketResource(factory)
# we server static files under "/" ..
webdir = os.path.abspath(pkg_resources.resource_filename("echows", "web"))
root = File(webdir)
# and our WebSocket server under "/ws" (note that Twisted uses
# bytes for URIs)
root.putChild(b"ws", resource)
# both under one Twisted Web Site
site = Site(root)
self.site = site
self.factory = factory
self.listener = reactor.listenTCP(self.port, site)
示例2: startService
# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import startFactory [as 别名]
def startService(self):
factory = WebSocketServerFactory("ws://localhost:%d" % self.port, debug=self.debug)
factory.protocol = EchoServerProtocol
factory.setProtocolOptions(allowHixie76=True) # needed if Hixie76 is to be supported
# FIXME: Site.start/stopFactory should start/stop factories wrapped as Resources
factory.startFactory()
resource = WebSocketResource(factory)
# we server static files under "/" ..
webdir = os.path.abspath(pkg_resources.resource_filename("echows", "web"))
root = File(webdir)
# and our WebSocket server under "/ws"
root.putChild("ws", resource)
# both under one Twisted Web Site
site = Site(root)
site.protocol = HTTPChannelHixie76Aware # needed if Hixie76 is to be supported
self.site = site
self.factory = factory
self.listener = reactor.listenTCP(self.port, site)
示例3: startFactory
# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import startFactory [as 别名]
def startFactory(self):
WebSocketServerFactory.startFactory(self)
self.setOptionsFromConfig()
log.msg("EchoWebSocketFactory started [speaking WebSocket versions %s]" % self.versions)
self.publishStats()