SpeechRecognizer.UDPClient.StartClient C# (CSharp) Méthode

StartClient() public méthode

Creates a connection to the RTP stream
public StartClient ( ) : void
Résultat void
        public void StartClient()
        {
            // Create new UDP client. The IP end point tells us which IP is sending the data
            client = new UdpClient(port);

            listening = true;
            listenerThread = new Thread(ReceiveCallback);
            listenerThread.Start();

            Console.WriteLine(" [UDPClient] Listening for packets on port " + port + "...");
        }

Usage Example

 /// <summary>
 /// Helper method for dependencies
 /// </summary>
 /// <param name="dep">The dependencies</param>
 /// <param name="shouldBeOn">Should the SRE associated with this microphone be turned on or not</param>
 private async void DepenedencyHelper(dynamic dep, bool shouldBeOn)
 {
     foreach (var mic in dep)
     {
         if ((string)mic.Value == "up")
         {
             if (mics.ContainsKey(mic.Key))
             {
                 SpeechRecognitionEngine sre = mics[mic.Key].Sre;
                 if (sre.AudioState == AudioState.Stopped && mics[mic.Key].ShouldBeOn)
                     sre.RecognizeAsync(RecognizeMode.Multiple);
             }
             else
             {
                 UDPClient client = new UDPClient(port);
                 client.StartClient();
                 AddInputMic(mic.Key, client, mic.Value, shouldBeOn);
                 port++;
             }
             await Query("microphone", "invite", new { ip = ipAddress, port = mics[mic.Key].Port }, new string[1] { mic.Key });
         }
         else
         {
             if (mics.ContainsKey(mic.Key))
             {
                 mics[(string)mic.Key].Client.StopClient();
                 SpeechRecognitionEngine sre = mics[mic.Key].Sre;
                 if (sre.AudioState != AudioState.Stopped && shouldBeOn)
                 {
                     sre.RecognizeAsyncCancel();
                     Logger.GetInstance().Debug("IT STOPPED!");
                 }
                 mics.Remove(mic.Key);
             }
         }
     }
 }