summaryrefslogtreecommitdiffstats
path: root/src/client/ClientBase.hpp
blob: f2439b84040a07b9354722f766402095ba2d8975 (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
34
35
36
37
38
#ifndef WC_CLIENTBASE_H
#define WC_CLIENTBASE_H

#ifdef _WIN32
	#include <winsock2.h>
#endif

#include "../const_vars.hpp"

class ClientBase {
protected:
#ifdef _WIN32
	SOCKET fd;
#else
	int fd;
#endif

	char out_buffer[max_msg_len]; // for message
	int out_buf_used;

	bool exit_flag;
	bool connection;
public:
	ClientBase(const char* ip, int port);
	virtual ~ClientBase();
	int ConstuctorError() const;

	int Run();
	void BreakLoop() { exit_flag = true; }
	
	virtual void HandleActions() {}
	virtual void AddMessage(const char *msg, const char spec_char) {}
	void SendMessage(const char *msg);
private:
	int InitSocket(const char* ip, int port);
};

#endif