How do AppRTC work in WebRTC mechanism ?
In this article, we illustrate how AppRTC do work.
Last updated
In this article, we illustrate how AppRTC do work.
Last updated
AppRTC is a WebRTC open source repo that implements two clients who can communicate with each other with webcam and voice. That works like a chatting room but only two persons in the room. When there have two clients in the room, they will exchange some messages for building a p2p connection and starting communication.
But it doesn’t the whole WebRTC main mechanism that is only data exchange and manages the connection process. So AppRTC is a sample system when the coder implements WebRTC, help them decrease the development time.
Manipulate AppRTC First, one client joins a room and waiting for the other client to join. At once, there are two clients in the room, they can chat with each other.
The AppRTC Implement (not include p2p mechanism) We divided into two part to illustrate AppRTC work. The first client join room and the second client join room.
The first client join room:
Get / for getting AppRTC home page.
Post /join/:room_id for registry room id into AppRTC and getting a Client ID to registry Signal Server.
Use Client ID to registry Signal Server (Collider Server)
send /ws {cmd: "register", "roomid":"", “clientid”: ""}
POST /message/:room_id/:client_id for storing p2p connection message into AppRTC Server.(About sdp、(ICE) candidate messages)
Waiting another sdp and (ICE) Candidate message.
The second client join room:
Get / for getting AppRTC home page.
Post /join/:room_id for registry room id into AppRTC and getting a Client ID to registry Signal Server and first client p2p connection cache(sdp, (ICE candidate)
According to cache generates a new p2p connection message and send it by WebSocket to the first client
Two clients communicate with each other through p2p.
The Collider Server API
The Collider server has two functions. one is HTTP, the other one is WebSocket. The WebSocket API is for the client to communicate with each other like registry and send these actions. The HTTP API is for AppRTC server sync room status.
numbers
parameters
illustration
1
{cmd: "register", "roomid":"", "clientid": ""}
join room
2
{cmd: "send", "roomid":"", "clientid": "", "msg":"JSON string"}
send message to the other client
numbers
parameters
illustration
1
post /bye/:room_id:/:client_id
delete collider room status
Conclusion In the AppRTC demo application, it follows Broker Architecture to coordinate p2p message exchange. Though the key-point is not the sdp and (ICE) candidate message exchanged method, but it still important to manage the exchange process. So if you read AppRTC open source, this article can help you modify this project.