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


Python Factory.users方法代码示例

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


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

示例1: startService

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import users [as 别名]
def startService(textbuffer, port, welcome, statusbar):
    addText(textbuffer, APP_NAME, LOG_INFO)
    addText(textbuffer, _("Version ") + APP_VERSION, LOG_INFO)
    addText(textbuffer, _("Attempting to start server at port ") + str(port) + "\n", LOG_INFO)
    addText(textbuffer, _("Creating Factory"), LOG_INFO)

    factory = Factory()
    factory.protocol = RPG
    factory.textbuffer = textbuffer
    factory.statusbar = statusbar
    factory.clients = []

    addText(textbuffer, _("Saving welcome message..."), LOG_INFO)
    factory.welcome = welcome
    f = open(PATH_WELCOME_MSG, "w")
    f.write(welcome)
    f.close()
    addText(textbuffer, _("Setting up Users datastructure"), LOG_INFO)
    factory.users = Users()
    addText(textbuffer, _("Listening for incoming connections..."), LOG_INFO)
    reactor.listenTCP(port, factory)
    reactor.run()
开发者ID:rhcarvalho,项目名称:SimplePythonChatter,代码行数:24,代码来源:serverProtocol.py

示例2: TinyFileSlave

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import users [as 别名]
class TinyFileSlave(Protocol):
	"""Slave server — currently just echos the result onto console."""
    def connectionMade(self):
        print "Master server connected"
 
    def connectionLost(self, reason):
        print "Master server disconnected"

    def dataReceived(self, data):
    	"""We've gotten a request. It comes in a protocol buffer form."""
        # get the request protocol buffer
        print "Received data"
        info = FileRequest()
        info.ParseFromString(data)
        print "Filename:", info.filename
        print "Request type:", info.request_type
        print "File contents:", info.contents





factory = Factory()
factory.users = {}
factory.protocol = TinyFileSlave

reactor.listenTCP(1112, factory)
print "TinyFile server started"
reactor.run()

开发者ID:jamesjwu,项目名称:TinyFiles,代码行数:31,代码来源:Fileserver.py


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