-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathncurses_client.h
54 lines (46 loc) · 1.19 KB
/
ncurses_client.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
50
51
52
53
54
//
// Created by nasirho on 2022/5/31.
//
#ifndef CHATROOM_NCURSES_CLIENT_H
#define CHATROOM_NCURSES_CLIENT_H
#include <ncurses.h>
#include <semaphore.h>
#include <thread>
#include <ncurses.h>
#include <string>
#include <cstring>
#include <csignal>
#include <thread>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "global.h"
struct NcursesType{
WINDOW* name_display_win;
int name_display_height;
int name_display_width;
WINDOW* message_display_win;
int message_display_height;
int message_display_width;
WINDOW* input_board_win;
int input_board_height;
int input_board_width;
sem_t message_display_mutex;
};
class client{
public:
client();
private:
static NcursesType ncurses_data;
static std::thread sendThread, recvThread;
static unsigned int startIndex;
static int client_socket;
static bool exitFlag;
static void ncurses_init();
static void ncurses_message_display(char* message, short color, bool isSystem);
static void ncurses_clear_line(WINDOW* win, int y, int x);
static void send_msg();
static void recv_msg();
static void stop_client(int signal);
};
#endif //CHATROOM_NCURSES_CLIENT_H