File: NodeJSDevToolsProtocol.h

package info (click to toggle)
codelite 14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (60 lines) | stat: -rw-r--r-- 2,158 bytes parent folder | download | duplicates (4)
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
#ifndef NODEJSDEVTOOLSPROTOCOL_H
#define NODEJSDEVTOOLSPROTOCOL_H

#include "MessageManager.h"
#include "NodeJSDebuggerBreakpoint.h"
#include "SocketAPI/clWebSocketClient.h"
#include <unordered_map>
#include <wx/arrstr.h>

class NodeDebugger;
typedef std::function<void(const JSONItem&)> ResultFunc_t;
class CommandHandler
{
public:
    ResultFunc_t action = nullptr;
    long m_commandID = wxNOT_FOUND;
    CommandHandler() {}
    CommandHandler(long commandID, const ResultFunc_t& func)
        : action(func)
        , m_commandID(commandID)
    {
    }
};

class NodeJSDevToolsProtocol
{
    NodeDebugger* m_debugger = nullptr;
    long message_id = 0;
    MessageManager m_handlers;
    std::unordered_map<long, CommandHandler> m_waitingReplyCommands;

protected:
    void SendSimpleCommand(clWebSocketClient& socket, const wxString& command,
                           const JSONItem& params = JSONItem(NULL));

    NodeJSDevToolsProtocol();

public:
    static NodeJSDevToolsProtocol& Get();
    virtual ~NodeJSDevToolsProtocol();
    void Clear();

    void SetDebugger(NodeDebugger* debugger) { this->m_debugger = debugger; }
    NodeDebugger* GetDebugger() { return m_debugger; }
    void SendStartCommands(clWebSocketClient& socket);
    void ProcessMessage(const wxString& msg, clWebSocketClient& socket);
    void Next(clWebSocketClient& socket);
    void StepIn(clWebSocketClient& socket);
    void StepOut(clWebSocketClient& socket);
    void Continue(clWebSocketClient& socket);
    void SetBreakpoint(clWebSocketClient& socket, const NodeJSBreakpoint& bp);
    void DeleteBreakpoint(clWebSocketClient& socket, const NodeJSBreakpoint& bp);
    void DeleteBreakpointByID(clWebSocketClient& socket, const wxString& bpid);
    void GetScriptSource(clWebSocketClient& socket, const wxString& scriptId);
    void Eval(clWebSocketClient& socket, const wxString& expression, const wxString& frameId);
    void GetObjectProperties(clWebSocketClient& socket, const wxString& objectId, wxEventType eventType);
    void CreateObject(clWebSocketClient& socket, const wxString& expression, const wxString& frameId);
};

#endif // NODEJSDEVTOOLSPROTOCOL_H