2022-12-29 10:52:13 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021-2022 Leroy Hopson <godot-xterm@leroy.geek.nz>
|
|
|
|
// SPDX-License-Identifier: MIT
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
#ifndef GODOT_XTERM_PIPE_H
|
|
|
|
#define GODOT_XTERM_PIPE_H
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
#include <godot_cpp/classes/ref_counted.hpp>
|
|
|
|
#include <godot_cpp/variant/packed_byte_array.hpp>
|
2021-07-02 19:27:34 +02:00
|
|
|
#include <uv.h>
|
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
class Pipe : public RefCounted {
|
|
|
|
GDCLASS(Pipe, RefCounted)
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
uv_pipe_t handle;
|
|
|
|
|
|
|
|
Pipe();
|
|
|
|
~Pipe();
|
|
|
|
|
|
|
|
void _init();
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
Error open(int fd, bool ipc);
|
2021-07-22 07:17:23 +02:00
|
|
|
void close();
|
2021-07-02 19:27:34 +02:00
|
|
|
int get_status();
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
Error write(PackedByteArray data);
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
|
|
|
|
public:
|
2021-07-16 09:31:13 +02:00
|
|
|
int status;
|
2021-07-02 19:27:34 +02:00
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2021-07-02 19:27:34 +02:00
|
|
|
private:
|
|
|
|
void _poll_connection();
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
static Error _translate_error(int err);
|
2021-07-02 19:27:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace godot
|
|
|
|
|
|
|
|
#endif // GODOT_XTERM_PIPE_H
|