diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-20 11:55:50 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-20 11:55:50 +0200 |
commit | 5876e74fa32881b41478cd67c5b0895161fbdc9c (patch) | |
tree | aa5ea781dde2ae1c06f40cbd81c988f7643ef491 /client/sock.cpp | |
parent | b854c4d6ac06c4a39006a086766deb90096c2998 (diff) |
add socket class + test async prompt messages
Diffstat (limited to 'client/sock.cpp')
-rw-r--r-- | client/sock.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/client/sock.cpp b/client/sock.cpp new file mode 100644 index 0000000..703ee24 --- /dev/null +++ b/client/sock.cpp @@ -0,0 +1,29 @@ +#include <unistd.h> +#include <cstdio> + +#include <thread> + +#include "sock.h" +#include "rl.h" + +PBSocket::PBSocket() { + printf("Init PBSocket!\n"); +} + +PBSocket::PBSocket(char* addr, uint16_t port) : PBSocket() { + connect(addr, port); +} + +void PBSocket::connect(char* addr, uint16_t port) { + printf("Connect to %s on port %d\n", addr, port); + + this->_thread = std::thread(&PBSocket::sock_task, this); +} + +void PBSocket::sock_task() { + while(1) { + sleep(3); + rl_printf("Testing asynchronous messages in prompt...\n"); + } +} + |