Hi Ben,
Thanks for your answer, you gave me the hint that I needed.

Using the TServerEventHandler I am now able to every time a user ask for a 
login.

public Object createContext(Thrift.Protocol.TProtocol input, 
Thrift.Protocol.TProtocol output)
    {
      var client = ((TSocket)input.Transport).TcpClient;
      _log.DebugFormat("Client {0} is now connected", 
client.Client.RemoteEndPoint.ToString());
      return input.Transport;

    }

Yours sincerely / Med venlig hilsen


René Winkler Sørensen
Software Development Engineer
Product Development, Service Engineering
Technology & Service Solutions (TSS)


Vestas Wind Systems A/S 
T: 83 11 39 97 
M: +45 2245 5971
[email protected]

Vestas Wind Systems A/S
This e-mail is subject to out e-mail disclaimer statement.
Please refer to http://www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.

-----Original Message-----
From: Ben Craig [mailto:[email protected]] 
Sent: 2. juni 2015 20:20
To: [email protected]
Cc: [email protected]
Subject: Re: client connect event

If you are using the C++ bindings, then you want to implement your own 
'IfFactory'.  For a service named 'Foo', the thrift compiler will make a 
C++ interface name 'FooIfFactory'.  It also generates a class inheriting 
from FooIfFactory named 'FooIfSingletonFactory'. 

FooIfFactory looks something like this:
class FooIfFactory {
 public:
  typedef FooIf Handler;

  virtual ~FooIfFactory() {}

  virtual FooIf* getHandler(const ::apache::thrift::TConnectionInfo& 
connInfo) = 0;
  virtual void releaseHandler(FooIf* /* handler */) = 0;
};

connInfo has pointers to the respective Transport classes, and you can 
dynamic_cast to get to the TSocket, and eventually to the IP.



From:   Stuart Reynolds <[email protected]>
To:     [email protected], 
Date:   06/02/2015 11:34 AM
Subject:        Re: client connect event
Sent by:        [email protected]



Subclassing is an easy way to inject missing functionality.  Override
methods that perform your own logic and call the superclass's version
of the method.
TSocket / TTransport are probably the right places to add this.

On Tue, Jun 2, 2015 at 2:19 AM, Rene Winkler Sørensen <[email protected]> 

wrote:
> My team is building a client/server application using thrift over 
rpc/tcp, we have one requirement from our stakeholder that we find very 
complicated in thrift. Every time a client opens a connection, we need to 
log the IP of that connection, it does not matter if the client calls 
anything, the log have to be there. So my question is, how do I do that, 
as far as I can see, the options are very limited. I found an event called 

TServerEventHandler, but I don't get the right information there as I see 
it, can anyone point me in the right direction if there is one??
>
>
> Yours sincerely / Med venlig hilsen
>
>
> René Winkler Sørensen
> Software Development Engineer
> Product Development, Service Engineering
> Technology & Service Solutions (TSS)
>
>
> Vestas Wind Systems A/S
> T: 83 11 39 97
> M: +45 2245 5971
> [email protected]<mailto:[email protected]>
>
> Vestas Wind Systems A/S
> This e-mail is subject to out e-mail disclaimer statement.
> Please refer to http://www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>

Reply via email to