diff options
author | Joursoir <chat@joursoir.net> | 2020-12-08 12:48:16 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2020-12-08 12:48:16 +0000 |
commit | 27cd9aded215835ffde615153600476bf9be2473 (patch) | |
tree | 0018a18a3d1b5891321d8218001c02128af82380 /src/client/ClientBase.hpp | |
parent | f7bd80577164da7540ad93fb2fa93df38168133b (diff) | |
download | want-chat-27cd9aded215835ffde615153600476bf9be2473.tar.gz want-chat-27cd9aded215835ffde615153600476bf9be2473.tar.bz2 want-chat-27cd9aded215835ffde615153600476bf9be2473.zip |
create base class for all client, add some functionality to gui
Diffstat (limited to 'src/client/ClientBase.hpp')
-rw-r--r-- | src/client/ClientBase.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/client/ClientBase.hpp b/src/client/ClientBase.hpp new file mode 100644 index 0000000..425929f --- /dev/null +++ b/src/client/ClientBase.hpp @@ -0,0 +1,28 @@ +#ifndef WC_CLIENTBASE_H +#define WC_CLIENTBASE_H + +#include "../const_vars.hpp" + +class ClientBase { +protected: + int fd; + char in_buffer[max_usermsg_len]; // for input + int in_buf_used; + + char out_buffer[max_msg_len]; // for message + int out_buf_used; + + bool exit_flag; +public: + ClientBase(const char* ip, int port); + virtual ~ClientBase(); + int ConstuctorError() const { return fd > -1 ? 0 : 1; } + + int Run(); + virtual void HandleActions() {} + virtual void ShowMessage(const char *msg) {} +private: + int CreateSocket(const char* ip, int port); +}; + +#endif
\ No newline at end of file |