Created
June 1, 2015 05:08
-
-
Save haydenjameslee/cb18338294d5739537a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using DaikonForge.VoIP; | |
using System; | |
public class MyLocalVoiceController : VoiceControllerBase | |
{ | |
public PhotonView photonView; | |
private DateTime lastTalking = DateTime.Now.AddMinutes(-1); | |
public override bool IsLocal | |
{ | |
get { return photonView.isMine; } | |
} | |
protected override void OnAudioDataEncoded( VoicePacketWrapper encodedFrame ) | |
{ | |
byte[] headers = encodedFrame.ObtainHeaders(); | |
GetComponent<PhotonView>().RPC("vc", PhotonTargets.Others, headers, encodedFrame.RawData); | |
encodedFrame.ReleaseHeaders(); | |
lastTalking = DateTime.Now; | |
} | |
[RPC] | |
void vc( byte[] headers, byte[] rawData ) | |
{ | |
if (!GetComponent<AudioSource>().enabled) return; | |
VoicePacketWrapper packet = new VoicePacketWrapper( headers, rawData ); | |
ReceiveAudioData( packet ); | |
} | |
public bool isTalking () | |
{ | |
return DateTime.Now.CompareTo(lastTalking.AddMilliseconds(100)) == -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment