summaryrefslogtreecommitdiffstats
path: root/src/server/rooms.hpp
blob: 9423be119e1c31d76054e05f3839ddec92753c0b (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
#ifndef ROOMREALIZATION_H
#define ROOMREALIZATION_H

const int std_id_lobby = -1;

class Server;
class ChatSession;

class ChatRoom {
    Server *the_server;
    const int code;
    // code == -1 it's lobby

    struct item {
        ChatSession *s;
        item *next;
    };
    item *first;
public:
    ChatRoom(Server *i_server, int id)
        : the_server(i_server), code(id), first(0) {}
    ~ChatRoom();

    void SendAll(const char *msg, ChatSession *except = 0);

    void HandleMessage(ChatSession *ses, const char *str);
    void HandleCommand(ChatSession *ses, int cmd_counter,
        char **commands);

    void AddSession(ChatSession *ses);
    void RemoveSession(ChatSession *ses);
    void CloseSession(ChatSession *ses);
};

#endif