private void Client_ConnectionChanged(Microsoft.SignalNow.Client.SignalNowClient signalNow, bool nowConnected, Exception ifErrorWhy) { this.connected = nowConnected; outgoingQueue = new ConcurrentQueue <SignalNowData>(); incomingQueue = new ConcurrentQueue <SignalNowData>(); ConnectionStatusChanged?.Invoke(connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected); }
void Client_ConnectionChanged(SignalNowClient signalNow, bool connected, Exception ifErrorWhy) { if (!connected) { cancelled = true; } }
private void OnDisable() { if (client != null) { Disconnect().Wait(); client = null; } }
void OnEnable() { if (client != null) { Disconnect(); client = null; } client = new Microsoft.SignalNow.Client.SignalNowClient(signalNowServer, 0, maxSimultaneousRequests); client.NewMessage += Client_NewMessage; client.RequestFailed += Client_RequestFailed; client.ConnectionChanged += Client_ConnectionChanged; client.PeerStatusChanged += Client_PeerStatusChanged; client.NewPeer += Client_NewPeer; if (autoStart) { StartSession(); } }
internal SignalNowMessageAction(SignalNowClient client, string recipient, bool groupRecipient, string messageType, string messagePayload, bool payloadIsJson, CancellationToken cancellationToken) { this.cancellationToken = cancellationToken; client.ConnectionChanged += Client_ConnectionChanged; this.action = new Action(() => { Started = true; try { client.SendMessage(recipient, groupRecipient, messageType, messagePayload, payloadIsJson).Wait(cancellationToken); } finally { Completed = true; } }); }
void Client_NewMessage(Microsoft.SignalNow.Client.SignalNowClient signalNow, string senderId, string messageType, string messagePayload) { SignalNowData[] dataArray = null; if (messageType.Equals(typeof(SignalNowTransformableData).Name, StringComparison.InvariantCultureIgnoreCase)) { try { dataArray = JsonConvert.DeserializeObject <SignalNowTransformableData[]>(messagePayload); } catch (Exception ex) { Debug.LogError($"Cannot process SignalNowTransformableData message. Exception: {ex.Message} ({ex.GetType().Name})"); } } if (dataArray != null) { foreach (var d in dataArray) { incomingQueue.Enqueue(d); } } }
private void Client_NewPeer(Microsoft.SignalNow.Client.SignalNowClient signalNow, Microsoft.SignalNow.Client.SignalNowPeer newPeer) { Debug.Log($"Peer {newPeer.UserName} is {newPeer.Status}");; }
void Client_PeerStatusChanged(Microsoft.SignalNow.Client.SignalNowClient signalNow, Microsoft.SignalNow.Client.SignalNowPeer peer) { Debug.Log($"Peer {peer.UserName} is {peer.Status}"); }
private void Client_RequestFailed(Microsoft.SignalNow.Client.SignalNowClient signalNow, string errorMessage) { Debug.LogError($"Signaling request failed: {errorMessage}"); RequestFailed?.Invoke(this, errorMessage); }