最小的工作示例——使用RxPY (v.1.2.4)Observable
逐字将'Hello world'
发送到回显服务器。在
客户:
from rx.concurrency.mainloopscheduler import TwistedScheduler
from rx.observable import Observable
from twisted.internet import reactor
from twisted.internet.protocol import ClientFactory
from twisted.protocols.basic import LineReceiver
class RxProtocol(LineReceiver):
def connectionMade(self):
Observable.from_list('Hello world'.split(' '), TwistedScheduler(reactor)).subscribe(self.sendLine)
def lineReceived(self, line):
print line
if __name__ == '__main__':
f = ClientFactory()
f.protocol = RxProtocol
reactor.connectTCP("localhost", 8000, f)
reactor.run()
服务器:来自twisted示例的简单echo服务器--echoserv.py
在服务器运行的情况下,启动客户端将提供:
^{pr2}$我做错什么了?在
目前没有回答
相关问题 更多 >
编程相关推荐