remote_client_connection.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "connection.h"
  3. #include "local_tasks.h"
  4. #include "remote_client_session.h"
  5. #include "remote_connection.h"
  6. #include <util/generic/object_counter.h>
  7. namespace NBus {
  8. namespace NPrivate {
  9. class TRemoteClientConnection: public TRemoteConnection, public TBusClientConnection {
  10. friend class TRemoteConnection;
  11. friend struct TBusSessionImpl;
  12. friend class TRemoteClientSession;
  13. private:
  14. TObjectCounter<TRemoteClientConnection> ObjectCounter;
  15. TSyncAckMessages AckMessages;
  16. TLocalTasks TimeToTimeoutMessages;
  17. IBusClientHandler* const ClientHandler;
  18. public:
  19. TRemoteClientConnection(TRemoteClientSessionPtr session, ui64 id, TNetAddr addr);
  20. inline TRemoteClientSession* GetSession();
  21. SOCKET CreateSocket(const TNetAddr& addr);
  22. void TryConnect() override;
  23. void HandleEvent(SOCKET socket, void* cookie) override;
  24. TBusMessage* PopAck(TBusKey id);
  25. void WriterFillStatus() override;
  26. void ClearOutgoingQueue(TMessagesPtrs& result, bool reconnect) override;
  27. void BeforeTryWrite() override;
  28. void ProcessReplyQueue();
  29. void MessageSent(TArrayRef<TBusMessagePtrAndHeader> messages) override;
  30. void TimeoutMessages();
  31. void ScheduleTimeoutMessages();
  32. void ReaderProcessMessageUnknownVersion(TArrayRef<const char> dataRef) override;
  33. EMessageStatus SendMessage(TBusMessage* pMes, bool wait) override;
  34. EMessageStatus SendMessageOneWay(TBusMessage* pMes, bool wait) override;
  35. EMessageStatus SendMessageImpl(TBusMessage*, bool wait, bool oneWay);
  36. void OpenConnection() override;
  37. };
  38. }
  39. }