Changeset 8 in chevmsgr for trunk/msgclnt.cpp
- Timestamp:
- 08/30/15 00:01:12 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/msgclnt.cpp
r6 r8 2 2 #include "msgclnt.h" 3 3 #include "msg.hpp" 4 5 #include <algorithm> 4 6 5 7 #include <stdlib.h> … … 182 184 std::vector<SFriend> chev::getFriendList() 183 185 { 186 std::vector<SFriend> friendList; 187 184 188 try 185 189 { 186 190 socket.send(request.getFriendList()); 187 } 188 catch (cf::exception & e) 189 { 190 LOG(e.what()); 191 } 192 return std::vector<SFriend>(); 193 } 194 195 std::string chev::getSessionID(const std::vector<std::string> & idList) 196 { 197 try 198 { 191 192 friendList = messageQ.pop(ProtocolType::FRIEND_LIST).getFriendList(); 193 } 194 catch (cf::exception & e) 195 { 196 LOG(e.what()); 197 } 198 199 return friendList; 200 } 201 202 std::string chev::getSessionID(std::vector<std::string> & idList) 203 { 204 try 205 { 206 if (idList.size() == 2) 207 std::sort(idList.begin(), idList.end()); 208 199 209 std::string concat = idList[0]; 200 210 201 for (int iter = 1 ; iter < idList.size(); iter++)202 concat += ","+ idList[iter];211 for (int iter = 1; iter < idList.size(); iter++) 212 concat += DELIMITER + idList[iter]; 203 213 204 214 if (sessionMap.find(concat) == sessionMap.end()) … … 206 216 socket.send(request.openSession(concat)); 207 217 208 std::string response = socket.receive().toString(); 209 Protocol::Message parser; 210 parser.parse(response); 211 212 if (!parser.get<bool>("result")) 218 Protocol::Message message = messageQ.pop(ProtocolType::SESSION_ID); 219 220 if (!message.get<bool>(ProtocolType::RESULT)) 213 221 THROW_EXCEPTION("failed to open session id"); 214 222 215 sessionMap[concat] = parser.get<std::string>("sess-id");223 sessionMap[concat] = message.get<std::string>(ProtocolType::SESSION_ID); 216 224 } 217 225 … … 247 255 { 248 256 SConversation c; 249 Protocol::Message parser= messageQ.pop(ProtocolType::CHAT);250 251 c.sessid = parser.get<std::string>(ProtocolType::SESSION_ID);252 c.message = parser.get<std::string>(ProtocolType::MESSAGE);253 c.sensitive = parser.get<int>(ProtocolType::SENSITIVE);254 c.isError = parser.get<bool>(ProtocolType::RESULT);255 256 c.from = parser.get<std::string>(ProtocolType::FROM);257 Protocol::Message message = messageQ.pop(ProtocolType::CHAT); 258 259 c.sessid = message.get<std::string>(ProtocolType::SESSION_ID); 260 c.message = message.get<std::string>(ProtocolType::MESSAGE); 261 c.sensitive = message.get<int>(ProtocolType::SENSITIVE); 262 c.isError = message.get<bool>(ProtocolType::RESULT); 263 264 c.from = message.get<std::string>(ProtocolType::FROM); 257 265 258 266 return c;
Note:
See TracChangeset
for help on using the changeset viewer.