summaryrefslogtreecommitdiffstats
path: root/src/client_clui/user.hpp
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2020-12-06 19:47:25 +0000
committerJoursoir <chat@joursoir.net>2020-12-06 19:47:25 +0000
commite99a03a838ddcf9eecadc10a7f71837afac3b99c (patch)
tree092ac919a8a8090df9c01536f5169e27952f7776 /src/client_clui/user.hpp
parent91d777da4f5baeac47b3097913b2407b45bc031e (diff)
downloadwant-chat-e99a03a838ddcf9eecadc10a7f71837afac3b99c.tar.gz
want-chat-e99a03a838ddcf9eecadc10a7f71837afac3b99c.tar.bz2
want-chat-e99a03a838ddcf9eecadc10a7f71837afac3b99c.zip
some changes in reg/auth; client: remove name in arguments
Diffstat (limited to 'src/client_clui/user.hpp')
-rw-r--r--src/client_clui/user.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/client_clui/user.hpp b/src/client_clui/user.hpp
new file mode 100644
index 0000000..a203320
--- /dev/null
+++ b/src/client_clui/user.hpp
@@ -0,0 +1,32 @@
+#ifndef USER_H
+#define USER_H
+
+#include "clui.hpp"
+#include "../const_vars.hpp"
+
+class Client {
+ 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;
+
+ Client(int i_fd) : fd(i_fd), in_buf_used(0),
+ out_buf_used(0), exit_flag(false) {}
+public:
+ ~Client() { close(fd); }
+
+ static Client *Start(const char* ip, int port);
+ void Run(ChatRoom *room);
+ void BreakLoop() { exit_flag = true; }
+ void HandleButton(ChatRoom *room);
+
+ void AddCharToBuffer(char ch);
+ void RemoveCharFromBuffer();
+ void SendMessage();
+};
+
+#endif \ No newline at end of file