public void BeginLoop(ManualResetEvent go) { //Call this before starting a peer connection SpitfireRtc.InitializeSSL(); //Add a stun server Spitfire.AddServerConfig(new ServerConfig { Host = "stun.l.google.com", Port = 19302, Type = ServerType.Stun, }); var started = Spitfire.InitializePeerConnection(); if (started) { go.Set(); //Keeps the RTC thread alive and active while (!Token.Token.IsCancellationRequested && Spitfire.ProcessMessages(1000)) { Spitfire.ProcessMessages(1000); } //Do cleanup here Console.WriteLine("WebRTC message loop is dead."); } }
/// <summary> /// Setup new generic RTCPeerConnection /// </summary> /// <returns></returns> public SpitfireRtc HandleNewPeer() { SpitfireRtc rtcPeerConnection = new SpitfireRtc(); rtcPeerConnection.AddServerConfig(new ServerConfig() { Host = "stun.1.google.com", Port = 19302, Type = ServerType.Stun }); SpitfireRtc.InitializeSSL(); rtcPeerConnection.InitializePeerConnection(); rtcPeerConnection.CreateDataChannel(new DataChannelOptions() { Id = 1, Label = "skeletonChannel", Reliable = false }); rtcPeerConnection.CreateDataChannel(new DataChannelOptions() { Id = 3, Label = "cloudChannel", Reliable = false }); SetupCallbacks(rtcPeerConnection); return(rtcPeerConnection); }
static void Main(string[] args) { //This is a bare bones example that shows the logic in which one might //Implement Spitfire into their application //TODO a full fledged example SpitfireRtc.EnableLogging(); var t = new WebRtcSession("a"); Console.Read(); }
/// <summary> /// Setup WebRTC events handlers /// </summary> private void SetupCallbacks(SpitfireRtc rtcPeerConnection) { rtcPeerConnection.OnIceCandidate += OnIceCandidate; rtcPeerConnection.OnDataChannelOpen += DataChannelOpen; rtcPeerConnection.OnDataChannelClose += OnDataChannelClose; rtcPeerConnection.OnDataMessage += HandleMessage; rtcPeerConnection.OnIceStateChange += IceStateChange; rtcPeerConnection.OnSuccessAnswer += OnSuccessAnswer; rtcPeerConnection.OnFailure += OnFail; rtcPeerConnection.OnError += OnError; rtcPeerConnection.OnSuccessOffer += OnSuccessOffer; }
private void button1_Click(object sender, EventArgs e) { Candidates = new List <SpitfireIceCandidate>(); Spitfire = new SpitfireRtc(); //Spitfire.AddServerConfig("stun:52.210.97.83:3478?transport=udp", string.Empty, string.Empty); Token = new CancellationTokenSource(); dynamic json = JsonConvert.DeserializeObject(textBox1.Text); foreach (var c in json.candidates) { Spitfire.AddIceCandidate(c.sdpMid.ToString(), c.sdpMLineIndex.ToObject <int>(), c.candidate.ToString()); } AddSession(json.sdp.sdp.ToString()); }
public void BeginLoop(ManualResetEvent go) { //Call this before starting a peer connection SpitfireRtc.InitializeSSL(); //Add a stun server Spitfire.AddServerConfig(new ServerConfig { Host = "stun.l.google.com", Port = 19302, Type = ServerType.Stun, }); if (Spitfire.InitializePeerConnection()) { go.Set(); //You only need this until the datachannel opens or the ice state is connected. while (!Token.Token.IsCancellationRequested && Spitfire.ProcessMessages(1000)) { Spitfire.ProcessMessages(1000); } } }
public void BeginLoop(ManualResetEvent go) { //Call this before starting a peer connection SpitfireRtc.InitializeSSL(); Spitfire.AddServerConfig(new ServerConfig { Host = "52.210.97.83", Username = "******", Password = "******", Port = 3478, Type = ServerType.Turn }); //Spitfire.AddServerConfig("turn:52.210.97.83:3478?transport=tcp", "dvw", "helloice1"); var started = Spitfire.InitializePeerConnection(); if (started) { go.Set(); //Keeps the RTC thread alive and active while (!Token.Token.IsCancellationRequested && Spitfire.ProcessMessages(1000)) { Spitfire.ProcessMessages(1000); } //Do cleanup here Console.WriteLine("WebRTC message loop is dead."); } }
public WebRtcSession(string id) { Id = id; Spitfire = new SpitfireRtc(44110, 44113); Token = new CancellationTokenSource(); }