DFVoice (VoIP) and SmartFox are not working in my client Unity

Hi guys,

I am trying to run voice over IP (by SmartFox server) using my purchased DFVoice package on Unity, my attempt was as follows:
On the first machine (let’s say a sender), I created an object and attached all required DFVoice components as well as a script as follows:

public class TestVoiceSender : VoiceControllerBase
{	
		byte[] headers;
		byte[] dataFrame;
	
		protected override void OnAudioDataEncoded (VoicePacketWrapper encodedFrame)
		{
				headers = encodedFrame.ObtainHeaders ();
				dataFrame = encodedFrame.RawData; 
				NetworkManager.Instance.SendDFVoiceAudio (headers, dataFrame);  
				encodedFrame.ReleaseHeaders ();				
		}
	
		public override bool IsLocal {
				get { 
                       return true;
		}
		}

}
}

The used Method “SendDFVoiceAudio” in NetworkManager class (which sends and receives from the server) contains of the following code:

public void SendDFVoiceAudio (byte[] header, byte[] dataFrame)  {

		ISFSObject parameters = new SFSObject ();
		Room room = smartFox.LastJoinedRoom;
		
            ByteArray h = new ByteArray (header);
		ByteArray d = new ByteArray (dataFrame);
	        parameters.PutByteArray("headers", h);
		parameters.PutByteArray("audio", d);

		parameters.PutInt ("userId", smartFox.MySelf.Id);
		Debug.Log ("Sent User Id: " + smartFox.MySelf.Id);
		
		smartFox.Send (new ExtensionRequest ("DFAudio", parameters, room));
		Debug.Log ("DFVoice Audio Sent");
		}

On the second machine (the receiver), I created a method in the NetworkManger class, and attached the NetworkManager class to Unity receiver object as follows:

public void OnAudioDataReceived (ISFSObject dt) {
senderUser = dt.GetInt (“userId”);
Debug.Log ("Received user id: " + senderUser);

			Sfs2X.Util.ByteArray headers = dt.GetByteArray("headers");
			Debug.Log ("Received Header Size: " + headers.Length);
		
			Sfs2X.Util.ByteArray audioData = dt.GetByteArray ("audio");
			Debug.Log ("Received Audio Size: " + audioData.Length);

			VoicePacketWrapper packet = new VoicePacketWrapper (headers.Bytes, audioData.Bytes);
			ReceiveAudioData (packet);
	                Debug.Log ("Audio received OK! ");
	}

public override bool IsLocal {
		get { 		
			return true;
		}
	}

Consoles on both machines as shown below giving me variable lengths of byte array of the audio when speaking on mic which is good, and however the sound does not appear on the second machine, so any help would highly be appreciated.
Sender machine:

On receiver machine:

Thanks.
Note: Most of code have been copied from DFVoice forum, but it still does not work.

Can you help me with this issue please?

[Answered on the DaikonForge forums, copy pasted here.]

public override bool IsLocal
{
    get{ return true; }
}

There is your problem. So, for an object which is receiving audio data over the network, if this returns true it will not play back audio data.
Basically, DFVoice assumes you have one voice controller object per player, in the same way that you might have, for example, one avatar per player. So, assuming you have clients A, B, and C, on client A you would have three of these objects - one object for client A, one object for client B, and one object for client C. When client A receives voice data sent from client B, it should pass that data to the object for client B.
Therefore, IsLocal should return true if the object it is attached to belongs to the local client, false otherwise. So in the aforementioned situation, on client A’s machine, the script on the object for client A would return true for IsLocal, whereas the other two (for client B and C) would return false. This way, if client A receives his own voice data, it is ignored and not played back (which would be distracting), but does play back voice data for clients B and C.

Additionally, keep in mind these objects need to be separate because each one maintains its own instance of the codec, and the Speex codec cannot properly handle decoding different “streams” of audio (meaning one instance of the codec cannot properly handle decoding audio from both client B and C for instance, for this you need two instances of the codec, therefore two different game objects).

Does this make sense?