本文整理汇总了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()
示例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()