Changeset 8 in chevmsgr for trunk/msg.cpp


Ignore:
Timestamp:
08/30/15 00:01:12 (9 years ago)
Author:
cheese
Message:

클라 UI 쪼끔 수정
프로토콜 메시지 좀 수정
클라 메시지 핸들링 추가

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/msg.cpp

    r6 r8  
    44    json::Object _obj;                          \
    55    makeTemplate(_obj, _type);                  \
    6 
    7 #define DELIMITER   "$"
    86
    97namespace Protocol
     
    1816    {
    1917        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;
    2038    }
    2139
     
    3351    void Request::makeTemplate(json::Object & obj, const std::string & type) const
    3452    {
    35         obj[ProtocolType::ID  ] = mID;
     53        obj[ProtocolType::ID] = mID;
    3654        obj[ProtocolType::TYPE] = type;
    3755    }
     
    5068        DECLARE_TEMPLATE_OBJECT(obj, ProtocolType::JOIN);
    5169
    52         obj[ProtocolType::ID ] = id;
    53         obj[ProtocolType::PW ] = pw;
     70        obj[ProtocolType::ID] = id;
     71        obj[ProtocolType::PW] = pw;
    5472        obj[ProtocolType::SMS] = sms;
    5573
     
    88106        DECLARE_TEMPLATE_OBJECT(obj, ProtocolType::CHAT);
    89107
    90         obj[ProtocolType::FROM      ] = mID;
     108        obj[ProtocolType::FROM] = mID;
    91109        obj[ProtocolType::SESSION_ID] = sessid;
    92         obj[ProtocolType::MESSAGE   ] = message;
    93         obj[ProtocolType::SENSITIVE ] = sensitive;
     110        obj[ProtocolType::MESSAGE] = message;
     111        obj[ProtocolType::SENSITIVE] = sensitive;
    94112
    95113        return json::Serialize(obj);
     
    117135        return json::Serialize(obj);
    118136    }
     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    }
    119158};
Note: See TracChangeset for help on using the changeset viewer.