Last change
on this file since 14 was 14, checked in by cheese, 9 years ago |
테스트 코드 추가
UI 모양 작업
채팅되는 상태까지 확인
|
File size:
1.5 KB
|
Line | |
---|
1 | #pragma once
|
---|
2 |
|
---|
3 | #include <string>
|
---|
4 | #include <vector>
|
---|
5 |
|
---|
6 | #include "msg.hpp"
|
---|
7 |
|
---|
8 | #include "cf/network.h"
|
---|
9 | #include "cf/task.h"
|
---|
10 |
|
---|
11 | typedef struct SConversation
|
---|
12 | {
|
---|
13 | // tell and listen
|
---|
14 | std::string sessid;
|
---|
15 | std::string message;
|
---|
16 | int sensitive;
|
---|
17 |
|
---|
18 | // only for listen
|
---|
19 | std::string from;
|
---|
20 | } SConversation;
|
---|
21 |
|
---|
22 | typedef struct SOpenSession
|
---|
23 | {
|
---|
24 | std::string sessid;
|
---|
25 | std::vector<std::string> idList;
|
---|
26 | } SOpenSession;
|
---|
27 |
|
---|
28 | typedef struct SCallback
|
---|
29 | {
|
---|
30 | int(*onListen)(SConversation &);
|
---|
31 | int(*onOpenSession)(SOpenSession &);
|
---|
32 | } SCallback;
|
---|
33 |
|
---|
34 | class MessageQ
|
---|
35 | {
|
---|
36 | private:
|
---|
37 | cf::task::mutex mutex;
|
---|
38 | std::vector<Protocol::Message> messageQ;
|
---|
39 |
|
---|
40 | public:
|
---|
41 | void push(const Protocol::Message & message);
|
---|
42 |
|
---|
43 | Protocol::Message pop(const std::string & requestType, bool isWait = true);
|
---|
44 | };
|
---|
45 |
|
---|
46 | class chev
|
---|
47 | {
|
---|
48 | private:
|
---|
49 | Protocol::Request request;
|
---|
50 | std::string error;
|
---|
51 | cf::network::tcp socket;
|
---|
52 | cf::task::thread listener;
|
---|
53 | cf::task::thread caller;
|
---|
54 |
|
---|
55 | MessageQ messageQ;
|
---|
56 |
|
---|
57 | std::map<std::string, std::string> sessionMap;
|
---|
58 |
|
---|
59 | public:
|
---|
60 | chev();
|
---|
61 |
|
---|
62 | ~chev();
|
---|
63 |
|
---|
64 | const std::string & getLastError() const;
|
---|
65 |
|
---|
66 | bool connect(const std::string & host, unsigned short port);
|
---|
67 |
|
---|
68 | bool sms(const std::string & phone);
|
---|
69 |
|
---|
70 | bool join(const std::string & id, const std::string & pw, const std::string & sms);
|
---|
71 |
|
---|
72 | bool login(const std::string & id, const std::string & pw);
|
---|
73 |
|
---|
74 | bool addFriend(const std::string & id);
|
---|
75 |
|
---|
76 | std::vector<SFriend> getFriendList();
|
---|
77 |
|
---|
78 | std::string getSessionID(const std::vector<std::string> & idList);
|
---|
79 |
|
---|
80 | bool tell(const SConversation & conversation);
|
---|
81 |
|
---|
82 | bool listen(const SCallback & callback);
|
---|
83 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.