Added xmrigDaemon to control xmrigMiner
Fixed some issues in CCClient and CCServer
This commit is contained in:
parent
2b97e2f4ff
commit
3f39ca31fd
15 changed files with 86 additions and 83 deletions
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <zconf.h>
|
||||
#include "Console.h"
|
||||
#include "interfaces/IConsoleListener.h"
|
||||
|
||||
|
@ -30,7 +31,10 @@ Console::Console(IConsoleListener *listener)
|
|||
: m_listener(listener)
|
||||
{
|
||||
m_tty.data = this;
|
||||
uv_tty_init(uv_default_loop(), &m_tty, 0, 1);
|
||||
|
||||
if (uv_tty_init(uv_default_loop(), &m_tty, 0, 1) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uv_is_readable(reinterpret_cast<uv_stream_t*>(&m_tty))) {
|
||||
return;
|
||||
|
@ -40,11 +44,6 @@ Console::Console(IConsoleListener *listener)
|
|||
uv_read_start(reinterpret_cast<uv_stream_t*>(&m_tty), Console::onAllocBuffer, Console::onRead);
|
||||
}
|
||||
|
||||
Console::~Console()
|
||||
{
|
||||
uv_read_stop(reinterpret_cast<uv_stream_t*>(&m_tty));
|
||||
uv_tty_reset_mode();
|
||||
}
|
||||
|
||||
void Console::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
|
||||
{
|
||||
|
@ -53,13 +52,14 @@ void Console::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t
|
|||
buf->base = console->m_buf;
|
||||
}
|
||||
|
||||
|
||||
void Console::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
if (nread < 0) {
|
||||
return uv_close(reinterpret_cast<uv_handle_t*>(stream), nullptr);
|
||||
}
|
||||
|
||||
if (nread == 1) {
|
||||
if (nread == 1 && static_cast<Console*>(stream->data)->m_listener && buf) {
|
||||
static_cast<Console*>(stream->data)->m_listener->onConsoleCommand(buf->base[0]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue