mk_tcp_private.h 1.44 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
xiongziliang committed
5
 *
xiongziliang committed
6 7 8
 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
xiongziliang committed
9 10 11 12 13 14 15
 */

#ifndef MK_TCP_PRIVATE_H
#define MK_TCP_PRIVATE_H

#include "mk_tcp.h"
#include "Network/TcpClient.h"
16
#include "Network/Session.h"
xiongziliang committed
17

夏楚 committed
18
class TcpClientForC : public toolkit::TcpClient {
19
public:
20
    using Ptr = std::shared_ptr<TcpClientForC>;
xiongziliang committed
21 22
    TcpClientForC(mk_tcp_client_events *events) ;
    ~TcpClientForC() override ;
夏楚 committed
23 24
    void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
    void onErr(const toolkit::SockException &ex) override;
xiongziliang committed
25
    void onManager() override;
夏楚 committed
26
    void onConnect(const toolkit::SockException &ex) override;
xiongziliang committed
27
    void setClient(mk_tcp_client client);
28
    std::shared_ptr<void> _user_data;
29
private:
xiongziliang committed
30 31 32 33
    mk_tcp_client_events _events;
    mk_tcp_client _client;
};

34
class SessionForC : public toolkit::Session {
35
public:
36 37
    SessionForC(const toolkit::Socket::Ptr &pSock) ;
    ~SessionForC() override = default;
夏楚 committed
38 39
    void onRecv(const toolkit::Buffer::Ptr &buffer) override ;
    void onError(const toolkit::SockException &err) override;
xiongziliang committed
40
    void onManager() override;
41
    std::shared_ptr<void> _user_data;
xiongziliang committed
42 43 44 45
    uint16_t _local_port;
};

#endif //MK_TCP_PRIVATE_H