public async Task Add(MockSignaling signaling) { await Task.Delay(MillisecondsDelay); list.Add(signaling); signaling.OnStart?.Invoke(signaling); }
public async Task Candidate(MockSignaling owner, CandidateData data) { await Task.Delay(MillisecondsDelay); foreach (var signaling in list.Where(e => e != owner)) { signaling.OnIceCandidate?.Invoke(signaling, data); } }
public async Task Answer(MockSignaling owner, DescData data) { await Task.Delay(MillisecondsDelay); foreach (var signaling in list.Where(e => e != owner)) { signaling.OnAnswer?.Invoke(signaling, data); } }
public async Task CloseConnection(MockSignaling signaling, string connectionId) { await Task.Delay(MillisecondsDelay); foreach (var element in list) { element.OnDestroyConnection?.Invoke(element, connectionId); } }
List <MockSignaling> FindList(MockSignaling owner, string connectionId) { if (!connectionIds.TryGetValue(connectionId, out var list)) { return(null); } list = list.Where(e => e != owner).ToList(); if (list.Count == 0) { return(null); } return(list); }
public async Task OpenConnection(MockSignaling signaling, string connectionId) { await Task.Delay(MillisecondsDelay); bool peerExists = connectionIds.TryGetValue(connectionId, out var list); if (!peerExists) { list = new List <MockSignaling>(); connectionIds.Add(connectionId, list); } list.Add(signaling); signaling.OnCreateConnection?.Invoke(signaling, connectionId, peerExists); }
public async Task Candidate(MockSignaling owner, CandidateData data) { await Task.Delay(MillisecondsDelay); var list = FindList(owner, data.connectionId); if (list == null) { Debug.LogWarning($"{data.connectionId} This connection id is not ready other session."); return; } foreach (var signaling in list.Where(e => e != owner)) { signaling.OnIceCandidate?.Invoke(signaling, data); } }
public async Task Answer(MockSignaling owner, DescData data) { await Task.Delay(MillisecondsDelay); var list = FindList(owner, data.connectionId); if (list == null) { Debug.LogError($"{data.connectionId} This connection id is not ready other session."); return; } foreach (var signaling in list) { signaling.OnAnswer?.Invoke(signaling, data); } }
public async Task CloseConnection(MockSignaling signaling, string connectionId) { await Task.Delay(MillisecondsDelay); bool peerExists = connectionIds.TryGetValue(connectionId, out var list); if (!peerExists || !list.Contains(signaling)) { Debug.LogError($"{connectionId} This connection id is not used."); } list.Remove(signaling); if (list.Count == 0) { connectionIds.Remove(connectionId); } signaling.OnDestroyConnection?.Invoke(signaling, connectionId); }
public async Task Offer(MockSignaling owner, DescData data) { await Task.Delay(MillisecondsDelay); var list = FindList(owner, data.connectionId); if (list == null) { Debug.LogWarning($"{data.connectionId} This connection id is not ready other session."); return; } data.polite = true; foreach (var signaling in list.Where(x => x != owner)) { signaling.OnOffer?.Invoke(signaling, data); } }
public async Task OpenConnection(MockSignaling signaling, string connectionId) { await Task.Delay(MillisecondsDelay); signaling.OnCreateConnection?.Invoke(signaling, connectionId, true); }
public async Task Remove(MockSignaling signaling) { await Task.Delay(MillisecondsDelay); list.Remove(signaling); }
public async Task CloseConnection(MockSignaling signaling, string connectionId) { await Task.Delay(MillisecondsDelay); signaling.OnDestroyConnection?.Invoke(signaling, connectionId); }