remote_client_session.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "remote_client_session_semaphore.h"
  3. #include "session_impl.h"
  4. #include <util/generic/array_ref.h>
  5. #include <util/generic/object_counter.h>
  6. #ifdef _MSC_VER
  7. #pragma warning(push)
  8. #pragma warning(disable : 4250) // 'NBus::NPrivate::TRemoteClientSession' : inherits 'NBus::NPrivate::TBusSessionImpl::NBus::NPrivate::TBusSessionImpl::GetConfig' via dominance
  9. #endif
  10. namespace NBus {
  11. namespace NPrivate {
  12. using TRemoteClientSessionPtr = TIntrusivePtr<TRemoteClientSession>;
  13. class TRemoteClientSession: public TBusClientSession, public TBusSessionImpl {
  14. friend class TRemoteClientConnection;
  15. friend class TInvokeOnReply;
  16. public:
  17. TObjectCounter<TRemoteClientSession> ObjectCounter;
  18. TRemoteClientSessionSemaphore ClientRemoteInFlight;
  19. IBusClientHandler* const ClientHandler;
  20. public:
  21. TRemoteClientSession(TBusMessageQueue* queue, TBusProtocol* proto,
  22. IBusClientHandler* handler,
  23. const TBusSessionConfig& config, const TString& name);
  24. ~TRemoteClientSession() override;
  25. void OnMessageReceived(TRemoteConnection* c, TVectorSwaps<TBusMessagePtrAndHeader>& newMsg) override;
  26. EMessageStatus SendMessageImpl(TBusMessage* msg, const TNetAddr* addr, bool wait, bool oneWay);
  27. EMessageStatus SendMessage(TBusMessage* msg, const TNetAddr* addr = nullptr, bool wait = false) override;
  28. EMessageStatus SendMessageOneWay(TBusMessage* msg, const TNetAddr* addr = nullptr, bool wait = false) override;
  29. int GetInFlight() const noexcept override;
  30. void FillStatus() override;
  31. void AcquireInFlight(TArrayRef<TBusMessage* const> messages);
  32. void ReleaseInFlight(TArrayRef<TBusMessage* const> messages);
  33. void ReleaseInFlightAndCallOnReply(TNonDestroyingAutoPtr<TBusMessage> request, TBusMessagePtrAndHeader& response);
  34. EMessageStatus GetMessageDestination(TBusMessage* mess, const TNetAddr* addrp, TBusSocketAddr* dest);
  35. void OpenConnection(const TNetAddr&) override;
  36. TBusClientConnectionPtr GetConnection(const TNetAddr&) override;
  37. };
  38. #ifdef _MSC_VER
  39. #pragma warning(pop)
  40. #endif
  41. }
  42. }