Changeset 8 in chevmsgr for trunk/msg.cpp
- Timestamp:
- 08/30/15 00:01:12 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/msg.cpp
r6 r8 4 4 json::Object _obj; \ 5 5 makeTemplate(_obj, _type); \ 6 7 #define DELIMITER "$"8 6 9 7 namespace Protocol … … 18 16 { 19 17 return get<std::string>("type"); 18 } 19 20 std::vector<SFriend> Message::getFriendList() const 21 { 22 json::Array ar = mObject[ProtocolType::FRIEND_LIST]; 23 24 std::vector<SFriend> friendList; 25 26 std::vector<json::Value>::iterator iter; 27 for (iter = ar.begin(); iter != ar.end(); iter++) 28 { 29 SFriend fr; 30 31 fr.id = (*iter)[ProtocolType::ID ]; 32 fr.name = (*iter)[ProtocolType::NAME]; 33 34 friendList.push_back(fr); 35 } 36 37 return friendList; 20 38 } 21 39 … … 33 51 void Request::makeTemplate(json::Object & obj, const std::string & type) const 34 52 { 35 obj[ProtocolType::ID 53 obj[ProtocolType::ID] = mID; 36 54 obj[ProtocolType::TYPE] = type; 37 55 } … … 50 68 DECLARE_TEMPLATE_OBJECT(obj, ProtocolType::JOIN); 51 69 52 obj[ProtocolType::ID 53 obj[ProtocolType::PW 70 obj[ProtocolType::ID] = id; 71 obj[ProtocolType::PW] = pw; 54 72 obj[ProtocolType::SMS] = sms; 55 73 … … 88 106 DECLARE_TEMPLATE_OBJECT(obj, ProtocolType::CHAT); 89 107 90 obj[ProtocolType::FROM 108 obj[ProtocolType::FROM] = mID; 91 109 obj[ProtocolType::SESSION_ID] = sessid; 92 obj[ProtocolType::MESSAGE 93 obj[ProtocolType::SENSITIVE 110 obj[ProtocolType::MESSAGE] = message; 111 obj[ProtocolType::SENSITIVE] = sensitive; 94 112 95 113 return json::Serialize(obj); … … 117 135 return json::Serialize(obj); 118 136 } 137 138 std::string Response::friendList(const std::vector<SFriend> & friendList) const 139 { 140 DECLARE_TEMPLATE_OBJECT(obj, ProtocolType::FRIEND_LIST); 141 142 json::Array ar; 143 std::vector<SFriend>::const_iterator iter; 144 for (iter = friendList.begin() ; iter != friendList.end() ; iter++) 145 { 146 json::Object fr; 147 148 fr[ProtocolType::ID ] = iter->id; 149 fr[ProtocolType::NAME] = iter->name; 150 151 ar.push_back(fr); 152 } 153 154 obj[ProtocolType::FRIEND_LIST] = ar; 155 156 return json::Serialize(obj); 157 } 119 158 };
Note:
See TracChangeset
for help on using the changeset viewer.