-
Notifications
You must be signed in to change notification settings - Fork 1
/
TypedClient.h
49 lines (39 loc) · 1.04 KB
/
TypedClient.h
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
39
40
41
42
43
44
45
46
47
48
49
/*
* TypedClient.h
*
* Created on: 08.04.2013
* Author: urandon
*/
#ifndef TYPEDCLIENT_H_
#define TYPEDCLIENT_H_
#include "BaseClient.h"
class TypedClient: public BaseClient {
public:
TypedClient(const char * ip, int port);
static const int PATTERN_LENGTH = 4;
static const int PREFIX_QUANTITY = 5;
static const char service_prefix[PREFIX_QUANTITY+1][PATTERN_LENGTH+1];
enum message_type {
U_BROADCAST, U_PRIVATE, // user's messages
S_BROADCAST, S_HUMAN, S_MACHINE, // server's messages
NO_TYPE // when type is not defined
};
struct message_t {
enum message_type type;
int length;
char * msg;
message_t(char * msg, enum message_type type);
message_t(const message_t & message);
~message_t();
};
virtual int check(struct timeval timeout);
virtual int act();
private:
message_queue_t queue[PREFIX_QUANTITY+1];
enum message_type recognize(char * message);
protected:
char * getMessage(message_type queue_no);
bool isEmpty(message_type queue_no);
int getLength(message_type queue_no);
};
#endif /* TYPEDCLIENT_H_ */