mirror of
				https://github.com/pion/webrtc.git
				synced 2025-10-31 02:36:46 +08:00 
			
		
		
		
	Remove global API for settings engine
Limit global API to the basics needed to construct a PeerConnection.
This commit is contained in:
		 backkem
					backkem
				
			
				
					committed by
					
						 Michiel De Backker
						Michiel De Backker
					
				
			
			
				
	
			
			
			 Michiel De Backker
						Michiel De Backker
					
				
			
						parent
						
							585f50ef86
						
					
				
				
					commit
					4fe2728721
				
			| @@ -14,9 +14,15 @@ const messageSize = 15 | ||||
|  | ||||
| func main() { | ||||
| 	// Since this behavior diverges from the WebRTC API it has to be | ||||
| 	// enabled using global switch. | ||||
| 	// Mixing both behaviors is not supported. | ||||
| 	webrtc.DetachDataChannels() | ||||
| 	// enabled using a settings engine. Mixing both detached and the | ||||
| 	// OnMessage DataChannel API is not supported. | ||||
|  | ||||
| 	// Create a SettingEngine and enable Detach | ||||
| 	s := webrtc.SettingEngine{} | ||||
| 	s.DetachDataChannels() | ||||
|  | ||||
| 	// Create an API object with the engine | ||||
| 	api := webrtc.NewAPI(webrtc.WithSettingEngine(s)) | ||||
|  | ||||
| 	// Everything below is the pion-WebRTC API! Thanks for using it ❤️. | ||||
|  | ||||
| @@ -29,8 +35,8 @@ func main() { | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	// Create a new RTCPeerConnection | ||||
| 	peerConnection, err := webrtc.NewPeerConnection(config) | ||||
| 	// Create a new RTCPeerConnection using the API object | ||||
| 	peerConnection, err := api.NewPeerConnection(config) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| @@ -81,7 +87,7 @@ func main() { | ||||
|  | ||||
| 	// Wait for the answer to be pasted | ||||
| 	answer := webrtc.SessionDescription{} | ||||
| 	signal.Decode(signal.MustReadStdin(), answer) | ||||
| 	signal.Decode(signal.MustReadStdin(), &answer) | ||||
|  | ||||
| 	// Apply the answer as the remote description | ||||
| 	err = peerConnection.SetRemoteDescription(answer) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user