-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial interface fro xshell_client
- Loading branch information
1 parent
26bca15
commit 1ea2ae9
Showing
4 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*************************************************************************** | ||
* 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_CLIENT_ZMQ_HPP | ||
#define XEUS_CLIENT_ZMQ_HPP | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace xeus | ||
{ | ||
class xclient_zmq_impl; | ||
|
||
class XEUS_ZMQ_API xclient_zmq | ||
{ | ||
public: | ||
explicit xclient_zmq(std::unique_ptr<xclient_zmq_impl> impl); | ||
~xclient_zmq(); | ||
|
||
void send_shell(const nl::json& message); | ||
|
||
nl::json check_shell_answer(); | ||
|
||
private: | ||
std::unique_ptr<xclient_zmq_impl> p_client_impl; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*************************************************************************** | ||
* 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_CLIENT_MESSENGER_HPP | ||
#define XEUS_CLIENT_MESSENGER_HPP | ||
|
||
#include <zmq.hpp> | ||
|
||
namespace xeus | ||
{ | ||
class xclient_messenger | ||
{ | ||
public: | ||
explicit xclient_messenger(zmq::context_t& context); | ||
virtual ~xclient_messenger(); | ||
|
||
void connect(); | ||
void stop_channels(); | ||
|
||
private: | ||
|
||
zmq::socket_t m_shell_controller; | ||
// Add more controller sockets as needed for other channels | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*************************************************************************** | ||
* 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_CLIENT_ZMQ_IMPL_HPP | ||
#define XEUS_CLIENT_ZMQ_IMPL_HPP | ||
|
||
#include "xshell_client.hpp" | ||
#include "xclient_messenger.hpp" | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace xeus | ||
{ | ||
class xclient_zmq_impl | ||
{ | ||
public: | ||
|
||
virtual ~xclient_zmq_impl() = default; | ||
|
||
xclient_zmq_impl(const xclient_zmq_impl&) = delete; | ||
xclient_zmq_impl& operator=(const xclient_zmq_impl&) = delete; | ||
|
||
xclient_zmq_impl(xclient_zmq_impl&&) = delete; | ||
xclient_zmq_impl& operator=(xclient_zmq_impl&&) = delete; | ||
|
||
xclient_messenger& get_client_messenger(); | ||
|
||
void start_channels(); | ||
|
||
void send_shell_message(const nl::json& message); | ||
|
||
void create_shell_client(); | ||
|
||
protected: | ||
|
||
xclient_zmq_impl() = default; | ||
|
||
private: | ||
|
||
using client_messenger_ptr = std::unique_ptr<xclient_messenger>; | ||
client_messenger_ptr p_messenger; | ||
|
||
xshell_client m_shell_client; | ||
// Other channel clients can be added here | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*************************************************************************** | ||
* 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_SHELL_CLIENT_HPP | ||
#define XEUS_SHELL_CLIENT_HPP | ||
|
||
#include "zmq.hpp" | ||
#include "nlohmann/json.hpp" | ||
#include "xeus/xkernel_configuration.hpp" | ||
#include "xeus-zmq/xauthentication.hpp" | ||
|
||
namespace xeus | ||
{ | ||
|
||
class xshell_client | ||
{ | ||
public: | ||
|
||
xshell_client(zmq::context_t& context, | ||
const std::string& user_name, | ||
const xeus::xconfiguration& config); | ||
|
||
~xshell_client(); | ||
|
||
protected: | ||
|
||
void send_on_shell(nl::json header, | ||
nl::json parent_header, | ||
nl::json metadata, | ||
nl::json content); | ||
|
||
nl::json receive_on_shell(); | ||
|
||
nl::json check_received_message(long timeout); | ||
|
||
zmq::socket& get_socket(); | ||
|
||
private: | ||
void send_message(nl::json header, | ||
nl::json parent_header, | ||
nl::json metadata, | ||
nl::json content, | ||
zmq::socket_t& socket, | ||
const xeus::xauthentication& auth); | ||
|
||
nl::json receive_message(zmq::socket_t& socket, | ||
const xeus::xauthentication& auth); | ||
|
||
using authentication_ptr = std::unique_ptr<xeus::xauthentication>; | ||
authentication_ptr p_authentication; | ||
|
||
zmq::socket_t m_socket; | ||
std::string m_end_point; | ||
std::string m_user_name; | ||
}; | ||
} | ||
|
||
#endif |