blob: 03afb872dce0acc50016db4d52f9259b07c38d08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#ifndef USER_H
#define USER_H
#include "clui.hpp"
#include "../const_vars.hpp"
const int maxlen_inbuf = max_line_len + max_name_len + 1;
const int maxlen_outbuf = max_line_len + 1;
class Client {
int fd;
char in_buffer[maxlen_inbuf]; // for input
int in_buf_used;
char out_buffer[maxlen_outbuf]; // for message
bool exit_flag;
Client(int i_fd)
: fd(i_fd), in_buf_used(0) { }
public:
~Client() { close(fd); }
static Client *Start(const char* ip, int port);
void Run(ChatRoom *room);
void HandleButton(ChatRoom *room);
void AddCharToBuffer(char ch);
void RemoveCharFromBuffer();
void SendMessage();
};
#endif
|