Can an application control the P2P connection of the SDK?

Source: Internet
Author: User

Yes. Since "anychat platform core SDK v2.8", a P2P Connection Control interface has been added. The previous anychat SDK client preferentially transmits data over the P2P network, followed by the server forwarding mode (when P2P is unavailable ), the specific processing mode is determined by the SDK and cannot be intervened by upper-layer applications. The new data stream transmission mode control interface in v2.8 allows upper-layer applications to control the P2P network transmission of the client, or server forwarding mode to meet the special application requirements of upper-layer applications.

 

You can dynamically change the connection mode and return the P2P connection status to the upstream layer (refer to: P2P connection status change message). You can also query the P2P connection status of a specified user through the upper layer (refer: brac_queryuserstate ).

 

If you need to disable P2P access for local users (do not actively establish P2P connections with other users or receive P2P connection requests from other users), the typical example code is as follows:

 

  1. // Set the P2P policy to Disabled 2. DWORD  dwP2PPolitic = 0; 3. BRAC_SetSDKOption(BRAC_SO_NETWOK_P2PPOLITIC,( const  char *)&dwP2PPolitic, sizeof ( DWORD ));

 

 

All data is forwarded by the server after local users' P2P connections are prohibited.

 

The default P2P connection mode of the SDK is "Server Control Mode" (P2P data transmission is preferred in this mode, and server Forwarding is performed when P2P Data fails). To restore to the default P2P connection mode, the typical sample code is as follows:

 

  1. // Set the P2P policy to the server Control Mode 2. DWORD  dwP2PPolitic = 1; 3. BRAC_SetSDKOption(BRAC_SO_NETWOK_P2PPOLITIC,( const  char *)&dwP2PPolitic, sizeof ( DWORD ));

 

For more information about P2P connection policies, refer to: how to set P2P connection policies for anychat

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.