aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/remote_client_connection.h
blob: fe80b7d2f97f3b98ffd490505545d817a0befeb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "connection.h"
#include "local_tasks.h"
#include "remote_client_session.h"
#include "remote_connection.h"

#include <util/generic/object_counter.h>

namespace NBus {
    namespace NPrivate {
        class TRemoteClientConnection: public TRemoteConnection, public TBusClientConnection {
            friend class TRemoteConnection;
            friend struct TBusSessionImpl;
            friend class TRemoteClientSession;

        private:
            TObjectCounter<TRemoteClientConnection> ObjectCounter;

            TSyncAckMessages AckMessages;

            TLocalTasks TimeToTimeoutMessages;

            IBusClientHandler* const ClientHandler;

        public:
            TRemoteClientConnection(TRemoteClientSessionPtr session, ui64 id, TNetAddr addr);

            inline TRemoteClientSession* GetSession();

            SOCKET CreateSocket(const TNetAddr& addr);

            void TryConnect() override;

            void HandleEvent(SOCKET socket, void* cookie) override;

            TBusMessage* PopAck(TBusKey id);

            void WriterFillStatus() override;

            void ClearOutgoingQueue(TMessagesPtrs& result, bool reconnect) override;

            void BeforeTryWrite() override;

            void ProcessReplyQueue();

            void MessageSent(TArrayRef<TBusMessagePtrAndHeader> messages) override;

            void TimeoutMessages();

            void ScheduleTimeoutMessages();

            void ReaderProcessMessageUnknownVersion(TArrayRef<const char> dataRef) override;

            EMessageStatus SendMessage(TBusMessage* pMes, bool wait) override;

            EMessageStatus SendMessageOneWay(TBusMessage* pMes, bool wait) override;

            EMessageStatus SendMessageImpl(TBusMessage*, bool wait, bool oneWay);

            void OpenConnection() override;
        };

    }
}