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


Python WebSocketServerFactory.port方法代码示例

本文整理汇总了Python中autobahn.websocket.WebSocketServerFactory.port方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerFactory.port方法的具体用法?Python WebSocketServerFactory.port怎么用?Python WebSocketServerFactory.port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autobahn.websocket.WebSocketServerFactory的用法示例。


在下文中一共展示了WebSocketServerFactory.port方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EchoServerProtocol

# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import port [as 别名]
            elif event.Key == "Volume_Mute":
                pass
            elif event.Key == "Volume_Down":
                pass
            elif event.Key == "Volume_Up":
                pass
            elif event.Key == "Launch_Media_Select":
                pass
            else:
                return True


class EchoServerProtocol(WebSocketServerProtocol):
    def onOpen(self):
        self.hook = HookHandlerThread()
        self.hook.socket = self
        self.hook.start()

    def onClose(self, wasClean, code, reason):
        if hasattr(self, "hook"):
            print "Closing %s" % self.hook.ident
            win32api.PostThreadMessage(self.hook.ident, win32con.WM_QUIT, 0, 0);
        print "Closed"

if __name__ == '__main__':
   factory = WebSocketServerFactory()
   factory.protocol = EchoServerProtocol
   factory.port = 8002
   reactor.listenTCP(8002, factory)
   reactor.run()
开发者ID:uniite,项目名称:GroundPlayer,代码行数:32,代码来源:server.py

示例2: tick_flames

# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import port [as 别名]
    def tick_flames():
        traceerr(GAME._flames_process)
        reactor.callLater(FLAME_TICK_TIME, tick_flames)

    def tick_actions():
        traceerr(GAME._actions_process)
        reactor.callLater(ACTION_TICK_TIME, tick_actions)

    def tick_bombs():
        traceerr(GAME._bombs_process)
        reactor.callLater(BOMB_TICK_TIME, tick_bombs)

    factory = WebSocketServerFactory()
    # TODO: choose a more sensible port
    # TODO: add a REST interface to get the port
    factory.port = 9000  # ugh, why do I have to do this twice?
    factory.protocol = GameProtocol
    reactor.listenTCP(interface=hostname, port=9000, factory=factory)

    reactor.listenTCP(factory=server.Site(ServerRoot(None)), interface=hostname, port=port)

    reactor.callWhenRunning(tick_flames)
    reactor.callWhenRunning(tick_actions)
    reactor.callWhenRunning(tick_bombs)

    print "Listening on: http://%s:%d" % (hostname, port)
    print "Admin uid:", ADMIN_UID

    reactor.run()
开发者ID:ahri,项目名称:bombastic,代码行数:31,代码来源:server.py


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