forked from DzZ01/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedis.h
70 lines (42 loc) · 1.19 KB
/
Redis.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// Created by daimiaopeng on 2019/11/17.
//
#ifndef CHAT_PROJECT_REDIS_H
#define CHAT_PROJECT_REDIS_H
#include "json.hpp"
#include <hiredis/hiredis.h>
#include "glog/logging.h"
#include <iostream>
#include <boost/regex.hpp>
#include <memory>
#include <set>
using json = nlohmann::json;
using namespace std;
class Redis {
private:
string ip;
u_int port;
redisContext *conn;
public:
Redis(string ip, u_int port, string passwd);
Redis(string ip, u_int port);
void init();
void pushMessageQueue(const string &message);
string getName(int fd);
string getName(const string &token);
int getFd(const string &name);
void setName(int fd, const string &name);
void delName(int fd);
set<string> geOnile();
redisContext *getConn() { return conn; };
auto redisReply_ptr(void *reply);
string login(const string &name, const string &passwd);
int registered(const string &name, const string &passwd);
int lenMessage();
string popMessageQueue();
int getRegisterNums();
void clearToken();
void setFd(int fd, const string &name);
void setToken(const string &token, const string &name);
};
#endif //CHAT_PROJECT_REDIS_H