File: tcpparent.h

package info (click to toggle)
amqp-cpp 4.3.27-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,384 kB
  • sloc: cpp: 10,021; ansic: 191; makefile: 95
file content (106 lines) | stat: -rw-r--r-- 2,244 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
 *  TcpParent.h
 *
 *  Interface to be implemented by the parent of a tcp-state. This is
 *  an _internal_ interface that is not relevant for user-space applications.
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2018 - 2021 Copernica BV
 */

/**
 *  Include guard
 */
#pragma once

/**
 *  Dependencies
 */
#include <openssl/ssl.h>

/**
 *  Begin of namespace
 */
namespace AMQP {

/**
 *  Forward declarations
 */
class TcpState;
class Buffer;

/**
 *  Class definition
 */
class TcpParent
{
public:
    /**
     *  Destructor
     */
    virtual ~TcpParent() = default;


    /**
     *  Method that is called when the TCP connection has been established
     *  @param  state
     */
    virtual void onConnected(TcpState *state) = 0;
    
    /**
     *  Method that is called right before a connection is secured and that allows userspac to change SSL
     *  @param  state
     *  @param  ssl
     *  @return bool
     */
    virtual bool onSecuring(TcpState *state, SSL *ssl) = 0;

    /**
     *  Method that is called when the connection is secured
     *  @param  state
     *  @param  ssl
     *  @return bool
     */
    virtual bool onSecured(TcpState *state, const SSL *ssl) = 0;

    /**
     *  Method to be called when data was received
     *  @param  state
     *  @param  buffer
     *  @return size_t
     */
    virtual size_t onReceived(TcpState *state, const Buffer &buffer) = 0;
    
    /**
     *  Method to be called when we need to monitor a different filedescriptor
     *  @param  state
     *  @param  fd
     *  @param  events
     */
    virtual void onIdle(TcpState *state, int socket, int events) = 0;

    /**
     *  Method that is called when an error occurs (the connection is lost)
     *  @param  state
     *  @param  error
     *  @param  connected
     */
    virtual void onError(TcpState *state, const char *message, bool connected = true) = 0;

    /**
     *  Method to be called when it is detected that the connection was lost
     *  @param  state
     */
    virtual void onLost(TcpState *state) = 0;
    
    /**
     *  The expected number of bytes
     *  @return size_t
     */
    virtual size_t expected() = 0;
};

/**
 *  End of namespace
 */
}