-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClientState.hpp
54 lines (45 loc) · 1.23 KB
/
ClientState.hpp
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
50
51
52
53
54
#pragma once
class Client; // Forward declaration
enum class ClientStateEnum
{
INITIAL,
AWAITING_UUID, // Client is not registered and needs a UUID.
AWAITING_NEW_AES, // Client is partially registered and requests a new AES
AWAITING_OLD_AES, // Client is signing in and needs the previous AES key.
CRC_VERIFYING, // Client is sending a file, and the CRC is being verified.
};
class ClientState
{
public:
friend class Client;
virtual ~ClientState() = default;
virtual void handleRequest(Client *client) = 0;
virtual void changeState(Client *client, const ClientStateEnum &newState);
protected:
ClientState() = default; // Prevent instantiation outside of client.
};
class InitialState : public ClientState
{
public:
void handleRequest(Client *client) override;
};
class AwaitingUUIDState : public ClientState
{
public:
void handleRequest(Client *client) override;
};
class AwaitingNewAESState : public ClientState
{
public:
void handleRequest(Client *client) override;
};
class AwaitingOldAESState : public ClientState
{
public:
void handleRequest(Client *client) override;
};
class CRCVerificationState : public ClientState
{
public:
void handleRequest(Client *client) override;
};