/// <summary> /// TODO: Documentation StartTurnPeer /// </summary> /// <param name="sid"></param> private void StartTurnPeer(String sid) { JingleSession jingleSession = this.JingleManager.FindSession(sid); if (jingleSession != null && jingleSession.Remote.Action == ActionType.session_initiate) { JingleContent jingleContent = jingleSession.Remote.GetContent(0); JingleIce jingleIce = jingleContent.GetElement <JingleIce>(0); foreach (JingleIceCandidate candidate in jingleIce.GetCandidates()) { if (candidate.Type == IceCandidateType.relay) { if (this.OnTurnStart != null) { this.OnTurnStart(this, candidate.EndPoint, sid); } if (this.OnConnectionTryEnded != null) { this.OnConnectionTryEnded(this, sid); } this.CancelStartingSession(); break; } } } }
/// <summary> /// TODO: Documentation CheckConnectivity /// </summary> /// <param name="sid"></param> private void CheckConnectivity(String sid) { if (this.turnSessions.ContainsKey(sid)) { this.holePuncher = new HolePuncher(this.turnSessions[sid].TurnManager.HostEP, sid); JingleSession jingleSession = this.JingleManager.FindSession(sid); JingleContent jingleContent = jingleSession.Remote.GetContent(0); JingleIce jingleIce = jingleContent.GetElement <JingleIce>(0); foreach (JingleIceCandidate remoteCandidate in jingleIce.GetCandidates()) { switch (remoteCandidate.Type) { case IceCandidateType.host: case IceCandidateType.prflx: case IceCandidateType.srflx: foreach (JingleIceCandidate localCandidate in this.localCandidates[sid]) { if (localCandidate.Type == remoteCandidate.Type) { this.holePuncher.AddEP(remoteCandidate.Priority, remoteCandidate.EndPoint); break; } } break; case IceCandidateType.relay: if (this.TurnSupported && jingleSession.Remote.Action == ActionType.session_accept) { this.turnSessions[sid].TurnManager.CreatePermission(new XorMappedAddress(remoteCandidate.RelatedEndPoint), this.turnSessions[sid].TurnAllocation); } break; } } if (!this.holePuncher.CanStart && this.TurnSupported) { this.StartTurnPeer(sid); } else { this.holePuncher.StartTcpPunch(this.HolePunchSuccess, this.HolePunchFailure); } } }