anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
redis.h (1428B)
1 /* 2 * 3 * (C) 2003-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 */ 8 9 namespace Redis 10 { 11 struct Reply 12 { 13 enum Type 14 { 15 NOT_PARSED, 16 NOT_OK, 17 OK, 18 INT, 19 BULK, 20 MULTI_BULK 21 } 22 type; 23 24 Reply() { Clear(); } 25 ~Reply() { Clear(); } 26 27 void Clear() 28 { 29 type = NOT_PARSED; 30 i = 0; 31 bulk.clear(); 32 multi_bulk_size = 0; 33 for (unsigned j = 0; j < multi_bulk.size(); ++j) 34 delete multi_bulk[j]; 35 multi_bulk.clear(); 36 } 37 38 int64_t i; 39 Anope::string bulk; 40 int multi_bulk_size; 41 std::deque<Reply *> multi_bulk; 42 }; 43 44 class Interface 45 { 46 public: 47 Module *owner; 48 49 Interface(Module *m) : owner(m) { } 50 virtual ~Interface() { } 51 52 virtual void OnResult(const Reply &r) = 0; 53 virtual void OnError(const Anope::string &error) { Log(owner) << error; } 54 }; 55 56 class Provider : public Service 57 { 58 public: 59 Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { } 60 61 virtual bool IsSocketDead() = 0; 62 63 virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0; 64 virtual void SendCommand(Interface *i, const Anope::string &str) = 0; 65 66 virtual bool BlockAndProcess() = 0; 67 68 virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0; 69 virtual void Unsubscribe(const Anope::string &pattern) = 0; 70 71 virtual void StartTransaction() = 0; 72 virtual void CommitTransaction() = 0; 73 }; 74 }