Friend solution for video intercom SDK Hall

Source: Internet
Author: User

 

Currently, anychat only provides a list of users in the room and business logic for users entering and exiting the room. The new version will enhance support for upper-layer business logic and provide a complete Hall friend solution.

Hall friends solutions include:
1. The Business Server can set the user's friend list, and the client can obtain the friend list without entering the room;
2. The client can receive notifications about the online or offline status of friends;
3. The Business Server can customize user attributes (such as name, signature, gender, and remarks) and synchronize them to the client. The client can obtain user attributes customized by the Business Server;

The client adds an API:

  1. # Define wm_gv_userinfoupdate wm_gv + 16 // <User Information Update notification, wparam (INT) indicates the user ID, and lparam (INT) indicates the update category
  2. # Define wm_gv_friendstatus wm_gv + 17 // <friend online status change, wparam (INT) indicates the friend user ID, lparam (INT) indicates the user's current activity status: 0 offline, 1 online
  3. // Obtain the user friend ID list
  4. Brac_api DWORD brac_getuserfriends (lpdword lpuseridarray, DWORD & dwusernum );
  5. // Obtain the online status of a friend
  6. Brac_api DWORD brac_getfriendstatus (DWORD dwfrienduserid, DWORD & dwstatus );
  7. // Obtain the user group ID list
  8. Brac_api DWORD brac_getusergroups (lpdword lpgroupidarray, DWORD & dwgroupnum );
  9. // Obtain the list of friends under the Group
  10. Brac_api DWORD brac_getgroupfriends (DWORD dwgroupid, lpdword lpuseridarray, DWORD & dwusernum );
  11. // Obtain user information
  12. Brac_api DWORD brac_getuserinfo (DWORD dwuserid, DWORD dwinfoid, tchar * lpinfoname, DWORD dwlen );
  13. // Obtain the user group name
  14. Brac_api DWORD brac_getgroupname (DWORD dwgroupid, tchar * lpgroupname, DWORD dwlen );

Copy code

The following APIs are added to the server:

  1. // User information control type definition (API: bras_userinfocontrol incoming parameters, onuserinfocontrol callback parameters)
  2. # Define bras_userinfo_ctrlcode_kickout 1 // <kickout the specified user from the system
  3. # Define bras_userinfo_ctrlcode_syncdata 2 // <synchronize data of the specified user to the client
  4. # Define bras_userinfo_ctrlcode_addgroup 20 // <Add a user group. wparam is the group ID and lpstrvalue is the group name.
  5. # Define bras_userinfo_ctrlcode_delgroup 21 // <delete a user group. wparam is the group ID.
  6. # Define bras_userinfo_ctrlcode_addfriend 22 // <Add a User Friend With wparam as the friend ID
  7. # Define bras_userinfo_ctrlcode_delfriend 23 // <delete a User Friend With wparam as the friend ID
  8. # Define bras_userinfo_ctrlcode_setgrouprelation 24 // <sets the relationship between friends and groups. wparam is the group ID and lparam is the friend ID, indicating that friends belong to a group.
  9. // Set user details
  10. Bras_api DWORD bras_setuserinfo (DWORD dwuserid, DWORD dwinfoid, lpctstr lpinfovalue, DWORD dwflags = 0 );
  11. // Obtain user details
  12. Bras_api DWORD bras_getuserinfo (DWORD dwuserid, DWORD dwinfoid, tchar * lpinfovalue, DWORD dwsize );
  13. // User Information Control
  14. Bras_api DWORD bras_userinfocontrol (DWORD dwuserid, DWORD dwctrlcode, DWORD wparam = 0, DWORD lparam = 0, lpctstr lpstrvalue = NULL );

Copy code

Server-side business logic processing process

Set the user's friend list, group list, and user attributes in the User Logon success event, and send the data synchronization command:

  1. // Callback function definition for successful User Login
  2. Typedef void (callback * bras_onuserloginaction_callback) (DWORD dwuserid, lpctstr szusername, DWORD dwlevel, lpctstr szipaddr, lpvoid lpuservalue );

Copy code

1. Add a user group

  1. DWORD dwgroupid = 1;
  2. Bras_userinfocontrol (dwuserid, bras_userinfo_ctrlcode_addgroup, dwgroupid, 0, "my friends ");
  3. Dwgroupid = 2;
  4. Bras_userinfocontrol (dwuserid, bras_userinfo_ctrlcode_addgroup, dwgroupid, 0, "company colleague ");

Copy code

2. 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

3. Set the relationship between friends and groups (that is, the group to which friends belong)

  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. Set User Information (User Information)

  1. Bras_setuserinfo (dwuserid, 1, "my signature ");
  2. Bras_setuserinfo (dwuserid, 2, "020-85276986 ");
  3. ......

Copy code

5. Synchronize the information set above to the client

  1. Bras_userinfocontrol (dwuserid, bras_userinfo_ctrlcode_syncdata, 0, 0 );

Copy code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.