In IM communication, usually need to manage their own small partners, often contact, important users need to identify in the same user list, so that they can quickly contact and view friends dynamic. So how can you do similar QQ friends list function, such as
Lobby Buddy Solutions include:
1, the Business Server can set the user's friend list, the client can get a friend list, do not need to enter the room;
2, the client can get friends on-line, offline status notification;
3, the Business Server can be customized to set any attributes of the user (such as name, signature, gender, notes, etc.) and can be synchronized to the client, the client can get the Business Server custom user attributes;
The following is a model in the market (Bai Rui Technology) powerful SDK as an example to do the function implementation instructions,
Client API Interface:
1.     # Define wm_gv_userinfoupdate  WM_GV + 16 ///& lt; user information update notification, wparam ( int id lparam ( int
2. #define Wm_gv_friendstatus WM_GV +///< Friends Online status change,wParam ( int ) indicates the friend user ID number, lParam ( int ) indicates the user's current active status: 0 offline, 1 online
3.
4. // get a list of user friend IDs
5. brac_api DWORD brac_getuserfriends (Lpdword lpuseridarray, dword&dwusernum);
6. // get Friends Online status
7. Brac_api DWORD Brac_getfriendstatus (DWORD Dwfrienduserid, dword&dwstatus);
8. // get a list of user group IDs
9. brac_api DWORD brac_getusergroups (Lpdword lpgroupidarray, dword&dwgroupnum);
// get the group below the Friends list
brac_api dwordbrac_getgroupfriends (DWORD dwgroupid, Lpdword Lpuseridarray, dword&dwusernum);
// get user information
Brac_api dwordbrac_getuserinfo (DWORD Dwuserid, DWORD dwinfoid, tchar* Lpinfoname, Dworddwlen);
// get the user group name
brac_api DWORD Brac_getgroupname (Dworddwgroupid, tchar* Lpgroupname, DWORD dwlen);
Server-Side API Interface :
1. // user Information control type definition (API:bras_userinfocontrol incoming parameters, Onuserinfocontrol callback parameters)
2. #define BRAS_USERINFO_CTRLCODE_KICKOUT 1///< to kick the specified user out of the system
3. #define BRAS_USERINFO_CTRLCODE_SYNCDATA 2///< Synchronize the specified user's data to the client
4.
5. #define Bras_userinfo_ctrlcode_addgroup///< Add user Group,WParam for group Id , lpstrvalue for group name
6. #define Bras_userinfo_ctrlcode_delgroup///< Delete user groups,WParam for group Id
7. #define Bras_userinfo_ctrlcode_addfriend///< Add a user friend,wParam as friend Id
8. #define Bras_userinfo_ctrlcode_delfriend///< Delete a user friend,wParam as friend Id
9. #define Bras_userinfo_ctrlcode_setgrouprelation///< to set the association relationship between friends and groups,wparam is a group ID,lParam is a friend ID, which indicates that a friend belongs to a group
.
One by one .
// set up user's details
Bras_api dwordbras_setuserinfo (DWORD Dwuserid, DWORD dwinfoid, LPCTSTR Lpinfovalue, dworddwflags=0); /c8>
// Get detailed information about the user
Bras_api dwordbras_getuserinfo (DWORD Dwuserid, DWORD dwinfoid, tchar* Lpinfovalue, dworddwsize);
// user Information Control
bras_api DWORD Bras_userinfocontrol (Dworddwuserid, DWORD Dwctrlcode, DWORD wparam=0, DWORD lparam=0, LP Ctstrlpstrvalue=null);
Server-side business logic processing flow
Set the user's buddy list, group list, user attributes, and send data synchronization instructions in the User logon success event: 1. // User Login Successful callback function definition 2. typedef void (callback* Bras_onuserloginaction_callback) (DWORD Dwuserid, LPCTSTR szUserName, DWORD DwL Evel, LPCTSTR szipaddr, LPVoid lpuservalue); Copy Code I. Adding groups of users 1. DWORD dwgroupid = 1; 2. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_addgroup, dwgroupid, 0, " my friend c8> "); 3. dwgroupid = 2; 4. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_addgroup, dwgroupid, 0, " colleagues of the company c3> "); Copy Code Second, add user friends 1. DWORD dwfrienduserid = 10010; 2. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_addfriend, Dwfrienduserid); 3. Dwfrienduserid = 10011; 4. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_addfriend, Dwfrienduserid); Copy Code Third, set the relationship between friends and groups (that is, which group a friend belongs to) 1. DWORD dwgroupid = 1; 2. DWORD dwfrienduserid = 10010; 3. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_setgrouprelation, dwGroupID, DwFriendUserId) ; 4. dwgroupid = 2; 5. Dwfrienduserid = 10011; 6. Bras_userinfocontrol (Dwuserid, Bras_userinfo_ctrlcode_setgrouprelation, dwGroupID, DwFriendUserId) ; Copy Code Iv. Setting up user information (user profile) 1. Bras_setuserinfo (Dwuserid, 1, " my signature "); 2. Bras_setuserinfo (Dwuserid, 2, "020-85276986"); 3 ..... Copy Code V. Synchronize the previously set data to the client 1. Bras_userinfocontrol (Dwuserid, bras_userinfo_ctrlcode_syncdata, 0, 0); Copy Code |
Instant Messenger buddy list business logic detailed