summaryrefslogtreecommitdiffstats
path: root/src/client/user.hpp
blob: a6e6c1578c502a7ec51970183a7e4657cd74e170 (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
#ifndef USER_H
#define USER_H

#include "clui.hpp"

const int max_line_length = 156;

class Client {
	int fd;
	char in_buffer[max_line_length]; // мы готовим к отправке
	char in_buf_used;
	char out_buffer[max_line_length]; // нам пришло
	char out_buf_used;
	bool ignoring;
	bool exit_flag;

	Client(int i_fd)
		: fd(i_fd), in_buf_used(0), out_buf_used(0), ignoring(false) { }
public:
	~Client() { close(fd); }

	static Client *Start(const char* ip, int port);
	void Run(ChatRoom *room);
	void HandleButton(ChatRoom *room);

	int getFd() const { return fd; } // not used
};

#endif