On Thu, May 6, 2010 at 8:58 PM, thrift thrift <[email protected]> wrote:
> Hi, Joel, > Thanks very much for your reply. > I read your implementation and the problem is that, for Java version, > there is TProcessorFactory.java, so you can overwrite getProcessor. But for > Cpp version, there is no TProcessorFactory.cpp. I think Cpp and Java > version > has different mechanism. Have you ever tried your ideas in Cpp version? > Thanks. > No, I haven't tried it in C++, but looking at the C++ source I don't think it should be that difficult for you to extend TThreadPoolServer or create your own that takes a TProcessorFactory as a constructor arg. Alternatively, you could provide your own TTransportFactory and use that as your hook, since that gets access to the Client right after the connection has been accepted. HTH, Joel > > 2010/5/7 Joel Meyer <[email protected]> > > > Yes, if I understood your question, you can accomplish this by providing > > your own TProcessorFactory. Here's an example of the code in Java: > > > > > > > http://github.com/JoelPM/BidiThrift/blob/master/Server/src/main/java/com/joelpm/bidiMessages/server/Server.java > > > > On Thu, May 6, 2010 at 5:06 PM, yh zhang <[email protected]> wrote: > > > > > The situation is like this: > > > We have several clients, let's say client1 and cient2, and each > > > client will start a callback server to receive message from server, and > > of > > > course, different callback servers should have different port number. > > > Inside server, we use TThreadPoolServer and we have a class(let's > > say > > > CClient) to inherit handler class (let's say CalculatorHandler() in > > > tutorial), in this way, we can create an instance of CClient and use it > > as > > > a > > > parameter to initial TThreadPoolServer server. But the problem is that > > if > > > we have several clients, we want to create our class instance for every > > > server thread (Now it can only be created when initial > TThreadedServer). > > Is > > > there way to create new class instance (CClient) when server accepts a > > new > > > client? (means that we want to create new class instance when each > server > > > thread is created) > > > Thanks very much. > > > > > >
