2010-04-14 2 views
1

Thrift를 사용하여 클라이언트를 만들고 서버를 관리하기 위해 this처럼 게임을 만들려고합니다. 그러나 Facebook의 Thrift 서버가 사용자를 "추적"할 수있는 방법, 즉 을 their service으로 호출 할 때 다시 자신을 식별 할 필요가 없다는 것을 알 수 없습니다. 단 하나의 핸들러가 서버에 생성되는이 그 예에서Thrift와의 "추적"연결

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

, 서버는 연결을 허용 무엇 :

생성 된 서버 스텁이 시사하는 바에 따르면,이 작업을 수행 할 수있는 방법이 없습니다 .

페이스 북은 모든 요청이 서버 당 하나의 처리기를 통해서만 라우팅되는 경우 어떻게 클라이언트가 서버에 연결되어 있는지 추적 할 수 있습니까?

답변

0

시도 server.setServerEventHandler. 새 클라이언트가 연결되면 코드가 호출되어 연결 별 컨텍스트 개체를 만들 수 있습니다.

+0

'serServerEventHandler'는 정보가 실제 핸들러 (OP의'attack()'참조)에 전달되지 않는다면 가능한 것입니다. – nhed