tags:

views:

31

answers:

0

I am trying to create a game using Thrift, so that the clients are the players, and the server manages the boards, much like this. However, I cannot figure out how Facebook's Thrift server can "track" the user, i.e. when calling attack() on their service, I do not have to identify myself again.

According to what the generated server stub suggests, there is no way to do this:

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;
}

In that example, there is only one handler being created for the server, and the server is what accepts connections.

How is Facebook able to keep track of what clients are connected to the server, if all requests are routed through only one handler per server?