In the development of network communication, peer-to technology everyone must be very familiar with, peer-to is a new application based on the Internet environment technology. One-to-peer technology is that people can connect directly to other users ' computers and Exchange files instead of connecting to the server to browse and download as they used to. Another important feature is changing the Internet's current state of being a big web site, returning to "non-centralized" and returning power to the user. The technology. The use of peer-to communication technology, can greatly reduce the load of the system server, and geometric multiples of the expansion of the capacity of the system, and will not because the number of online users too much to cause the server network congestion. Now has the advanced technology is Bai Rui Technology anychat products.
Anychat for audio and video applications that do not pass through the server, the technology is based on the communication technology, the core of which is the firewall traversal. Beginning with the V2.8.6 version of the Anychat Platform Core SDK, the Anychat SDK has opened the kernel-to-peer connection strategy to the upper layer, allowing applications to intervene in the core's peer-to-peer connection to meet the needs of applications in a variety of situations.
The typical code for setting up a peer to connect policy is as follows:
1.DWORD dwp2ppolitic = 3;
2.brac_setsdkoption (Brac_so_network_p2ppolitic, (constchar*) &dwp2ppolitic,sizeof (DWORD));
The current open-to-peer connection strategy includes the following values:
The "0" prohibits peer connection, does not actively connect with other users, and does not accept peer-connected requests initiated by other users;
"1" server control p2p[default], automatically with all users in the current room to establish peer-to;
"2" upper-level application control peer-to connect, do not actively connect with other users, but can accept other user-initiated connection requests, but the application can be issued with the specified user to establish peer connection instructions, received the instructions of the upper application, and then try to establish a peer-to connect with the user;
"3" based on the need to establish a peer-to-peer connection, when it is necessary to establish a connection (such as requesting the other side of the audio, video data), it will automatically try to establish a peer-to connect with the user, but also automatically accept other users ' peer-to request;
When a peer connection is successful, or when it is broken, the upper-level application is notified via a peer-to change message.
Due to the limited number of peer-to-peer resources per client (up to 30 users per client), different application environments need to set different peer-to-peer policies.
The Anychat SDK is the "server control peer-to" policy by default, and when the user enters the room, it will proactively establish peer-to-peer with all users in the room, which is suitable for applications with no more than 50 users in the same room (considering the possible unsuccessful connection with some clients). If the number of users in the same room is large, it is recommended that the upper-level application use "upper-level application Control-Peer connection" or "Connect on demand" mode, so that clients can establish peer-to-peer with the users they want, rather than being occupied by unrelated users.
When the peer connection policy can be initialized successfully after the dynamic adjustment, but only the "no-Peer connection" mode is set, will be disconnected from the other user's peer-to, set other modes, will not disconnect the existing peer-to. When the client is set to the "Prohibit peer connection" policy, all audio, video data (including self-passed to other users, other users to themselves) will be transferred through the server, which can be used in some special applications.
The best strategy for all peer connections is "build on demand", but do not use it as the SDK's default peer-to-peer policy, primarily because the policy is new and the server control peer policy is set to the default connection policy for compatibility with older versions of the SDK.
When set to "upper-level app control-to-peer connection", the interface provided by the SDK can be actively connected to the specified user, with the typical code as follows:
1.DWORD Dwtargetuserid = 100;
2.brac_setsdkoption (Brac_so_network_p2pconnect, (constchar*) &dwtargetuserid,sizeof (DWORD));
We recommend an application platform, all use the same peer-to connect strategy, otherwise there may be special circumstances, such as: a users using the "upper application control peer-connected" policy, B users adopt the "server control peer-to" policy, two users into the room, Although the top-level app does not issue a user a request to connect to the B user, there is a user-to-peer connection between the A and B users because the B user is actively establishing a connection with the a user.
Communication technology of audio-video-to-peer connection