summaryrefslogtreecommitdiffstats
path: root/src/server/ChatRoom.hpp
blob: 183dcc143c55b7c178a33b57b5141f03c1fe827f (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
39
40
41
42
43
44
45
46
47
48
#ifndef WC_CHATROOM_H
#define WC_CHATROOM_H

#include "../const_vars.hpp"

#define DB_BUFFER_SIZE 128

const char first_reg[] = "First you must register using /reg";
const char first_login[] = "First you must log in using /login";
const int std_id_lobby = -1;
const int max_room_lenpass = 24;

class ChatServer;
class UserInfo;
class StorageOfUsers;

class ChatRoom {
    ChatServer *the_server;
    const int code; // if code == std_id_lobby then it's lobby
    char secret_pass[max_room_lenpass];

    StorageOfUsers *users;
public:
    ChatRoom(ChatServer *i_server, int id, char *pass);
    ~ChatRoom();

    void HandleMessage(UserInfo *u, const char *str);
    void HandleCommand(UserInfo *u, int cmd_counter,
        char **commands); // in _cmd

    const char *GetSecretPass();

    void AddSession(UserInfo *u);
    void RemoveSession(UserInfo *u);
    void CloseSession(UserInfo *u);

    static unsigned long Hash(const char *str); // in _cmd
private:
    static char **ParseToArg(const char *input, int &arrc); // in _cmd
    static bool CheckForbiddenSymbols(const char *str); // in _cmd

    bool CheckEnterNickname(UserInfo *u, const char *name);
    bool CheckEnterPassword(UserInfo *u, const char *pass);

    // IsPasswordRight
};

#endif