【发布时间】:2014-09-09 07:10:00
【问题描述】:
到目前为止,我已经使用 Twisted 框架为聊天应用程序开发了一个服务器,但我很难弄清楚如何实现存储某个人的照片。
我的第一个想法是我可以将图像存储在本地[这是最好的方法]并处理它,但正如我之前所说,我无法弄清楚如何解析照片。我的意思是如何发送它到服务器?
应该从客户端[iOS应用]中选择照片并发送到服务器,但正如我所说,我不明白它是如何工作的。
我应该在 dataReceived 中添加一些内容还是应该执行其他操作?
到目前为止我做了什么
from twisted.internet import reactor
from twisted.internet.protocol import Factory , Protocol
class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
def connectionLost(self , reason):
self.factory.clients.remove(self)
def dataReceived(self,data):
#do a lot of processing which works
factory = Factory()
factory.protocol=IphoneChat
factory.clients = []
reactor.listenTCP(8023,factory)
print "IPhone Chat server started"
reactor.run()
任何建议或想法都会对我很有帮助。
【问题讨论】:
标签: python ios twisted twisted.client