Changeset 6 in chevmsgr for trunk/msgclnt.h
- Timestamp:
- 08/29/15 02:20:50 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/msgclnt.h
r5 r6 9 9 #include "cf/task.h" 10 10 11 typedef struct S Friend11 typedef struct SConversation 12 12 { 13 std::string id; 14 std::string name; 15 } SFriend; 13 // tell and listen 14 std::string sessid; 15 std::string message; 16 int sensitive; 17 bool isError; 16 18 17 // for callback 19 // only for listen 20 std::string from; 21 } SConversation; 18 22 19 typedef struct SResultResponse 23 class MessageQ 20 24 { 21 bool result; 22 bool isError;23 } SResultResponse;25 private: 26 cf::task::mutex mutex; 27 std::vector<Protocol::Message> messageQ; 24 28 25 typedef struct SReceivedMessage 26 { 27 std::string sessid; 28 std::string sender; 29 std::string message; 30 bool isError; 31 } SReceivedMessage; 29 public: 30 void push(const Protocol::Message & parser); 32 31 33 typedef int (* callback_onResultResponse)(SResultResponse &); 34 typedef int (* callback_onReceiveMessage)(SReceivedMessage &); 35 36 typedef struct SCallback 37 { 38 callback_onResultResponse result; 39 callback_onReceiveMessage message; 40 } SCallback; 32 Protocol::Message pop(const std::string & requestType); 33 }; 41 34 42 35 class chev 43 36 { 44 37 private: 45 Message::Request request;38 Protocol::Request request; 46 39 std::string error; 47 40 cf::network::tcp socket; 48 41 cf::task::thread listener; 49 SCallback callback; 42 43 MessageQ messageQ; 44 45 std::map<std::string, std::string> sessionMap; 50 46 51 47 public: 52 48 chev(); 49 50 ~chev(); 51 52 const std::string & getLastError() const; 53 53 54 54 bool connect(const std::string & host, unsigned short port); … … 64 64 std::vector<SFriend> getFriendList(); 65 65 66 bool sendMessage(const std::string & friendid, const std::string & sessionID, const std::string & message);66 std::string getSessionID(const std::vector<std::string> & idList); 67 67 68 // call once 69 bool runReceiver(const SCallback & cb); 68 bool tell(const SConversation & conversation); 70 69 71 const std::string & getLastError();70 SConversation listen(); 72 71 };
Note:
See TracChangeset
for help on using the changeset viewer.