ShellSession.h 1.21 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3 4 5
 *
 * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
 *
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.
xzl committed
9 10 11 12 13 14
 */

#ifndef SRC_SHELL_SHELLSESSION_H_
#define SRC_SHELL_SHELLSESSION_H_

#include <functional>
xiongziliang committed
15
#include "Common/config.h"
xzl committed
16
#include "Util/TimeTicker.h"
17
#include "Network/TcpSession.h"
xiongziliang committed
18
using namespace toolkit;
xzl committed
19

xiongziliang committed
20
namespace mediakit {
xzl committed
21

22
class ShellSession: public TcpSession {
xzl committed
23
public:
24 25
    ShellSession(const Socket::Ptr &_sock);
    virtual ~ShellSession();
26

27
    void onRecv(const Buffer::Ptr &) override;
xiongziliang committed
28
    void onError(const SockException &err) override;
29
    void onManager() override;
30

xzl committed
31
private:
32 33 34 35 36 37 38 39 40
    inline bool onCommandLine(const string &);
    inline void pleaseInputUser();
    inline void pleaseInputPasswd();
    inline void printShellPrefix();

    function<bool(const string &)> _loginInterceptor;
    string _strRecvBuf;
    Ticker _beatTicker;
    string _strUserName;
xzl committed
41 42
};

xiongziliang committed
43
} /* namespace mediakit */
xzl committed
44 45

#endif /* SRC_SHELL_SHELLSESSION_H_ */