void DecodeAudio(object _rawData) { //Convert incoming data to a CNetworkStream. CNetworkStream _cAudioDataStream = (CNetworkStream)_rawData; //Pull relevant information out of the network stream. int iFrequency = _cAudioDataStream.ReadInt(); int iNumSamples = _cAudioDataStream.ReadInt(); int iNumEncodedBytes = _cAudioDataStream.ReadInt(); byte[] baEncodedData = _cAudioDataStream.ReadBytes(iNumEncodedBytes); CNetworkViewId cSenderViewID = _cAudioDataStream.ReadNetworkViewId(); // Decode short[] saDecodedFrames = new short[iNumSamples]; int iNumDecodedBytes = m_eDecoder.Decode(baEncodedData, 0, iNumEncodedBytes, saDecodedFrames, 0, false); //Debug.Log("Decoded audio data size: " + iNumDecodedBytes + " : " + saDecodedFrames.Length); //Populate a new struct which can be accessed later. DecodeInformation decodedFrameInfo; decodedFrameInfo.saDecodedData = saDecodedFrames; decodedFrameInfo.iFrequency = iFrequency; decodedFrameInfo.cSenderViewID = cSenderViewID; decodedFrameInfo.iNumSamples = iNumSamples; s_decodedFrames.Enqueue(decodedFrameInfo); }
static public void UnserializeElementEvents(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { while (_cStream.HasUnreadData) { // Get the DUIElement and its network view CDUIElement duiElement = CNetwork.Factory.FindObject(_cStream.ReadNetworkViewId()).GetComponent <CDUIElement>(); // Get the interaction notification EElementNotificationType notification = (EElementNotificationType)_cStream.ReadByte(); // Based on the notification type, update the clients of the event switch (notification) { case EElementNotificationType.OnClick: int click = _cStream.ReadInt(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { click }); break; case EElementNotificationType.OnDoubleClick: int dClick = _cStream.ReadInt(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { dClick }); break; case EElementNotificationType.OnPress: bool isPressed = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isPressed }); break; case EElementNotificationType.OnSelect: bool isSelected = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isSelected }); break; case EElementNotificationType.OnHover: bool isHovered = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isHovered }); break; case EElementNotificationType.OnDrag: float deltaX = _cStream.ReadFloat(); float deltaY = _cStream.ReadFloat(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { deltaX, deltaY }); break; case EElementNotificationType.OnDragStart: NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null); break; case EElementNotificationType.OnDragEnd: NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null); break; case EElementNotificationType.OnScroll: float delta = _cStream.ReadFloat(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { delta }); break; default: break; } } }