예제 #1
0
        // Connect / Disconnect
        public void Connect(string roomName, string appKey, UInt64 clientIdentifier)
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            Plugin.MatcherConnect(_nativeMatcher, roomName, appKey, clientIdentifier);
        }
        public int Channels()
        {
            if (_nativeAudioOutputStream == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioOutputStream");
            }

            return(Plugin.AudioOutputStreamGetChannels(_nativeAudioOutputStream));
        }
예제 #3
0
        // Disconnect
        public void Disconnect()
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            Plugin.MatcherDisconnect(_nativeMatcher);
        }
예제 #4
0
        public bool ProcessPlaybackFrame(float[] audioData)
        {
            if (_nativeAudioPreprocessor == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioPreprocessor");
            }

            return(Plugin.AudioPreprocessorProcessPlaybackFrame(_nativeAudioPreprocessor, audioData, audioData.Length));
        }
예제 #5
0
        public int Channels()
        {
            if (_nativeMicrophone == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Microphone");
            }

            return(Plugin.MicrophoneGetChannels(_nativeMicrophone));
        }
예제 #6
0
        public bool Start()
        {
            if (_nativeMicrophone == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Microphone");
            }

            return(Plugin.MicrophoneStart(_nativeMicrophone));
        }
예제 #7
0
        public void Disconnect()
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            Plugin.ClientDisconnect(_nativeClient);
        }
예제 #8
0
        // Metadata
        public int ClientIndex()
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            return(Plugin.ClientGetClientIndex(_nativeClient));
        }
        // Send audio data
        public bool SendRawAudioData(float[] audioData)
        {
            if (_nativeAudioInputStream == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioInputStream");
            }

            return(Plugin.AudioInputStreamSendRawAudioData(_nativeAudioInputStream, audioData, audioData.Length));
        }
예제 #10
0
        public bool GetAudioData(float[] audioData)
        {
            if (_nativeMicrophone == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Microphone");
            }

            return(Plugin.MicrophoneGetAudioData(_nativeMicrophone, audioData, audioData.Length));
        }
예제 #11
0
        public void ContinueConnectionWithPingTimes(PingResult[] pingResults)
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            Plugin.MatcherContinueConnectionWithPingTimes(_nativeMatcher, pingResults, pingResults.Length);
        }
예제 #12
0
        public string GetServerError()
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            return(Plugin.MatcherGetServerError(_nativeMatcher));
        }
        // Set desired sample rate. Native plugin will resample to it automatically.
        // Set to 0.0f to reset it back to the sample rate that's sent from the server.
        public void SetSampleRate(int sampleRate)
        {
            if (_nativeAudioOutputStream == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioOutputStream");
            }

            Plugin.AudioOutputStreamSetSampleRate(_nativeAudioOutputStream, sampleRate);
        }
예제 #14
0
        // RPC
        public bool SendRPCMessage(byte[] data, int dataLength, bool reliable)
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            return(Plugin.ClientSendRPCMessage(_nativeClient, data, dataLength, reliable));
        }
예제 #15
0
        public double RoomTime()
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            return(Plugin.ClientGetRoomTime(_nativeClient));
        }
예제 #16
0
        public void Stop()
        {
            if (_nativeMicrophone == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Microphone");
            }

            Plugin.MicrophoneStop(_nativeMicrophone);
        }
예제 #17
0
        // Tick
        public int Tick()
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            return(Plugin.MatcherTick(_nativeMatcher));
        }
예제 #18
0
        // Connect / Disconnect
        public void Connect(UInt64 clientIdentifier, byte[] connectToken)
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            // TODO: Connect/Disconnect need to fail gracefully if called multiple times.
            Plugin.ClientConnect(_nativeClient, clientIdentifier, connectToken, connectToken.Length);
        }
        public int StreamID()
        {
            if (_nativeAudioOutputStream == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioOutputStream");
            }

            // TODO: It might be worth caching this if the calls are expensive
            return(Plugin.AudioOutputStreamGetStreamID(_nativeAudioOutputStream));
        }
예제 #20
0
        // Tick
        public int Tick()
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            // TODO: ClientTick should do its own deltaTime calculation. It will be more precise and will prevent the client and server from getting out of sync.
            return(Plugin.ClientTick(_nativeClient));
        }
        public bool GetAudioData(float[] audioData)
        {
            if (_nativeAudioOutputStream == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("AudioOutputStream");
            }

            // TODO: Fix this
            return(Plugin.AudioOutputStreamGetAudioData(_nativeAudioOutputStream, audioData, audioData.Length) > 0);
        }
예제 #22
0
        // Network Statistics
        public NetworkInfo GetNetworkStatistics()
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            NetworkInfo networkInfo;

            Plugin.ClientGetNetworkStatistics(_nativeClient, out networkInfo);
            return(networkInfo);
        }
예제 #23
0
        public byte[] GetConnectToken()
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            int    connectTokenLength  = Plugin.MatcherGetConnectTokenLength(_nativeMatcher);
            IntPtr connectTokenPointer = Plugin.MatcherGetConnectToken(_nativeMatcher);

            byte[] connectToken = new byte[connectTokenLength];
            Marshal.Copy(connectTokenPointer, connectToken, 0, connectTokenLength);
            return(connectToken);
        }
예제 #24
0
        // Audio
        public AudioInputStream CreateAudioInputStream(bool voice, int sampleRate, int channels)
        {
            if (_nativeClient == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Client");
            }

            if (sampleRate <= 0)
            {
                throw new ArgumentException("Attempting to create audio stream with invalid sample rate (" + sampleRate + ").");
            }
            if (channels <= 0)
            {
                throw new ArgumentException("Attempting to create audio stream with an invalid number of channels (" + channels + ").");
            }

            IntPtr nativeAudioInputStream = Plugin.ClientCreateAudioInputStream(_nativeClient, voice, sampleRate, channels);

            AudioInputStream audioInputStream = new AudioInputStream(nativeAudioInputStream);

            _audioInputStreams.Add(audioInputStream);

            return(audioInputStream);
        }
예제 #25
0
        public string[] GetIPsToPing()
        {
            if (_nativeMatcher == IntPtr.Zero)
            {
                throw RealtimeNativeException.NativePointerIsNull("Matcher");
            }

            int numberOfAddressesToPing = Plugin.MatcherGetNumberOfIPsToPing(_nativeMatcher);

            if (numberOfAddressesToPing <= 0)
            {
                return new string[] {}
            }
            ;

            List <string> addressesToPing = new List <string>(numberOfAddressesToPing);

            for (int i = 0; i < numberOfAddressesToPing; i++)
            {
                addressesToPing.Add(Plugin.MatcherGetAddressToPingAtIndex(_nativeMatcher, i));
            }

            return(addressesToPing.ToArray());
        }