【发布时间】:2011-02-08 01:53:45
【问题描述】:
我正在尝试使用 Thrift 创建游戏,这样客户端就是玩家,服务器管理棋盘,就像 this。但是,我无法弄清楚 Facebook 的 Thrift 服务器如何“跟踪”用户,即在 their service 上调用 attack() 时,我不必再次表明自己的身份。
根据生成的服务器存根提示,没有办法做到这一点:
int main(int argc, char **argv) {
int port = 9090;
shared_ptr<ConnectFourHandler> handler(new ConnectFourHandler());
shared_ptr<TProcessor> processor(new ConnectFourProcessor(handler));
shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
server.serve();
return 0;
}
在该示例中,只为服务器创建了一个处理程序,并且服务器是接受连接的对象。
如果所有请求仅通过每个服务器的一个处理程序路由,Facebook 如何跟踪连接到服务器的客户端?
【问题讨论】: