Skip to content

Commit

Permalink
Moved zmq dependent implementation of xdap_tcp_client to src
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Apr 11, 2024
1 parent 42a6f73 commit 5aa8ba8
Show file tree
Hide file tree
Showing 5 changed files with 546 additions and 405 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ set(XEUS_ZMQ_SOURCES
${XEUS_ZMQ_SOURCE_DIR}/xcontrol.hpp
${XEUS_ZMQ_SOURCE_DIR}/xcontrol.cpp
${XEUS_ZMQ_SOURCE_DIR}/xdap_tcp_client.cpp
${XEUS_ZMQ_SOURCE_DIR}/xdap_tcp_client_impl.cpp
${XEUS_ZMQ_SOURCE_DIR}/xdap_tcp_client_impl.hpp
${XEUS_ZMQ_SOURCE_DIR}/xdebugger_base.cpp
${XEUS_ZMQ_SOURCE_DIR}/xheartbeat.cpp
${XEUS_ZMQ_SOURCE_DIR}/xheartbeat.hpp
Expand Down
58 changes: 14 additions & 44 deletions include/xeus-zmq/xdap_tcp_client.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Martin Renou *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XEUS_DAP_TCP_CLIENT_HPP
#define XEUS_DAP_TCP_CLIENT_HPP

#include <functional>
#include <deque>
#include <memory>
#include <string>

#include "zmq.hpp"
#include "nlohmann/json.hpp"
#include "xeus/xkernel_configuration.hpp"
#include "xeus/xeus_context.hpp"

#include "xauthentication.hpp"
#include "xeus-zmq.hpp"

namespace nl = nlohmann;
Expand Down Expand Up @@ -42,6 +49,8 @@ namespace xeus
const std::string& session_id);
};

class xdap_tcp_client_impl;

class XEUS_ZMQ_API xdap_tcp_client
{
public:
Expand All @@ -53,7 +62,7 @@ namespace xeus

using event_callback = std::function<void(const nl::json&)>;

virtual ~xdap_tcp_client() = default;
virtual ~xdap_tcp_client();

xdap_tcp_client(const xdap_tcp_client&) = delete;
xdap_tcp_client& operator=(const xdap_tcp_client&) = delete;
Expand All @@ -74,8 +83,6 @@ namespace xeus
const xdap_tcp_configuration& dap_config,
const event_callback& cb);

const std::string& parent_header() const;

void forward_event(nl::json message);
void send_dap_request(nl::json message);

Expand All @@ -84,46 +91,9 @@ namespace xeus

private:

using queue_type = std::deque<std::string>;

zmq::message_t get_tcp_id() const;
void init_tcp_socket(const std::string& tcp_end_point);
void finalize_tcp_socket(const std::string& tcp_end_point);
void handle_header_socket();
void handle_control_socket();
void handle_tcp_socket(queue_type& message_queue);
void append_tcp_message(std::string& buffer);
void process_message_queue();
void handle_init_sequence();

virtual void handle_event(nl::json message) = 0;

zmq::socket_t m_tcp_socket;
zmq::message_t m_socket_id;

zmq::socket_t m_publisher;
zmq::socket_t m_controller;
zmq::socket_t m_controller_header;

dap_tcp_type m_dap_tcp_type;
dap_init_type m_dap_init_type;

std::string m_user_name;
std::string m_session_id;

event_callback m_event_callback;

using authentication_ptr = std::unique_ptr<xeus::xauthentication>;
authentication_ptr p_auth;

// Saves parent header for future debug events
std::string m_parent_header;

bool m_request_stop;
bool m_wait_attach;

queue_type m_message_queue;
queue_type m_stopped_queue;
std::unique_ptr<xdap_tcp_client_impl> p_impl;
};
}

Expand Down
Loading

0 comments on commit 5aa8ba8

Please sign in to comment.