From Perl Gibbon, 4 Years ago, written in Plain Text.
- view diff
Embed
  1. using SignalWire.Relay;
  2. using SignalWire.Relay.Calling;
  3. using System;
  4. using System.Threading.Tasks;
  5.  
  6. namespace josh
  7. {  
  8.     internal class Program
  9.     {  
  10.         public static void Main()
  11.         {  
  12.             using (Client client = new Client("f3dffdbf-e5ac-4511-a15f-XXXXXXXXXXX", "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
  13.             {  
  14.                 // Assign callbacks
  15.                 client.OnReady += c =>
  16.                 {  
  17.                     // This callback cannot block, so create a threaded task
  18.                     Task.Run(() =>
  19.                     {                                                     //cell           //signalwire
  20.                         DialResult resultDial = client.Calling.DialPhone("+1931298XXXX", "+1334212XXXX");
  21.  
  22.                         if (resultDial.Successful)
  23.                         {  
  24.                             // Your call has been answered, use resultDial.Call to access it
  25.                             Console.Write(resultDial.Call);
  26.                             // Play an audio file, block until it's finished or an error occurs
  27.                             resultDial.Call.PlayAudio("https://cdn.signalwire.com/default-music/welcome.mp3");
  28.                         }
  29.                     });
  30.                 };
  31.  
  32.                 // Connect the client
  33.                 client.Connect();
  34.  
  35.                 // Prevent exit until a key is pressed
  36.                 Console.Write("Press any key to exit...");
  37.                 Console.ReadKey(true);
  38.             }
  39.         }
  40.     }
  41. }
  42.