How to separate Playback & Recording in Did activate audio session

1- Did activate audio session get called in both receiveing and transmiting what the best practice to handle Playback & Recording.

2- how to playback audio after that cuse in background websocket get killed "Software caused connection abort".

Thanks in advance.🙏🏻

Your app should track the user’s transmission/receiving state internally to determine whether to configure your audio session for playback or recording. For example, your PTChannelManagerDelegate will receive a callback to channelManager(_:channelUUID:didBeginTransmittingFrom:) before calling channelManager(_:channelUUID:didActivateAudioSession:) if the user is beginning an outgoing transmission.

This gives you an opportunity to update the internal state of your app so that you can configure your audio session for accordingly. This also provides your app with an opportunity to reestablish your network connections to your backend server so that audio can be received/sent over the network.

Note that for the best performance we recommend setting the AVAudioSession category to playAndRecord during initial app start up and do not change it during the recording process. Changing the audio category when beginning a transmission can introduce significant delay.

How to separate Playback & Recording in Did activate audio session
 
 
Q