Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 void Client_ConnectionChanged(SignalNowClient signalNow, bool connected, Exception ifErrorWhy)
 {
     if (!connected)
     {
         cancelled = true;
     }
 }
Ejemplo n.º 3
0
 private void OnDisable()
 {
     if (client != null)
     {
         Disconnect().Wait();
         client = null;
     }
 }
Ejemplo n.º 4
0
    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();
        }
    }
Ejemplo n.º 5
0
        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;
                }
            });
        }
Ejemplo n.º 6
0
    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);
            }
        }
    }
Ejemplo n.º 7
0
 private void Client_NewPeer(Microsoft.SignalNow.Client.SignalNowClient signalNow, Microsoft.SignalNow.Client.SignalNowPeer newPeer)
 {
     Debug.Log($"Peer {newPeer.UserName} is {newPeer.Status}");;
 }
Ejemplo n.º 8
0
 void Client_PeerStatusChanged(Microsoft.SignalNow.Client.SignalNowClient signalNow, Microsoft.SignalNow.Client.SignalNowPeer peer)
 {
     Debug.Log($"Peer {peer.UserName} is {peer.Status}");
 }
Ejemplo n.º 9
0
 private void Client_RequestFailed(Microsoft.SignalNow.Client.SignalNowClient signalNow, string errorMessage)
 {
     Debug.LogError($"Signaling request failed: {errorMessage}");
     RequestFailed?.Invoke(this, errorMessage);
 }