当前位置: 首页>>代码示例>>Python>>正文


Python WebSocketServerFactory.startFactory方法代码示例

本文整理汇总了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)
开发者ID:Anggi-Permana-Harianja,项目名称:autobahn-python,代码行数:27,代码来源:echoservice.py

示例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)
开发者ID:Avnerus,项目名称:AutobahnPython,代码行数:29,代码来源:echoservice.py

示例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()
开发者ID:Inspire2Innovate,项目名称:crossbar,代码行数:7,代码来源:echowebsocket.py


注:本文中的autobahn.websocket.WebSocketServerFactory.startFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。