本文整理汇总了Python中autobahn.websocket.WebSocketServerFactory.stopFactory方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerFactory.stopFactory方法的具体用法?Python WebSocketServerFactory.stopFactory怎么用?Python WebSocketServerFactory.stopFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.websocket.WebSocketServerFactory
的用法示例。
在下文中一共展示了WebSocketServerFactory.stopFactory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DWS
# 需要导入模块: from autobahn.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.websocket.WebSocketServerFactory import stopFactory [as 别名]
class DWS(WebSocketServerProtocol):
# setup the logger
logger = logging.getLogger("DWS")
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
def onMessage(self, msg, binary):
self.logger.debug("Got Message %s" % msg)
try:
#self.sendMessage(msg, binary)
data = msg.split(',')
x = data[0].split(':')[1]
y = data[1].split(':')[1]
#self.logger.debug("X: %s, Y: %s " % (x, y))
if self.gc:
self.gc.drive(x,y)
else:
pass
self.logger.debug("no drive train access")
except:
self.logger.warn("Error processing message")
def __init__(self, gc=None):
self.gc = gc
self.factory = WebSocketServerFactory("ws://localhost:9000")
self.factory.protocol = DWS
self.running = True
self.logger.debug("initialized")
def serve_forever(self):
self.logger.debug("serving...")
listenWS(self.factory)
reactor.run()
def shutdown(self):
self.logger.debug("shutdown called")
reactor.stop()
self.logger.debug("reactor stopped, stopping factory...")
self.factory.stopFactory()
self.factory.doStop()
del self.factory
self.logger.debug("shutdown complete")
del self