public void Restore()
        {
            if (m_Filler != null)
            {
                m_Filler.enabled = m_WasFillerEnabled;
            }

            if (m_HideInVr)
            {
                gameObject.SetActive(m_WasActive);
                return;
            }

            m_RectTransform.SetParent(m_InitialParent);
            m_RectTransform.SetSiblingIndex(m_SiblingIndex);

            m_RectTransform.anchorMin = m_AnchorMin;
            m_RectTransform.anchorMax = m_AnchorMax;
            m_RectTransform.pivot     = m_Pivot;

            m_RectTransform.localPosition    = m_Position;
            m_RectTransform.localEulerAngles = m_Rotation;
            m_RectTransform.localScale       = m_Scale;

            OnRestored?.Invoke();
        }
Exemplo n.º 2
0
        public void Restore(int amount)
        {
            OnRestored.Invoke();

            if (_current + amount > _maximum)
            {
                _current = _maximum;
            }
            else
            {
                _current += amount;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Restore event
 /// </summary>
 /// <param name="obj">object</param>
 private static void OnRestoredHandle(ConnectionFailedEventArgs obj)
 {
     //Invoke event
     OnRestored?.Invoke(obj);
 }
Exemplo n.º 4
0
        public Client(
            string project,
            string token,
            string host        = null,
            string certificate = null,
            string agent       = null,
            UncertifiedConnectParams uncertifiedConnectParams = null,
            bool jwt = false,
            TimeSpan?connectDelay   = null,
            TimeSpan?connectTimeout = null,
            TimeSpan?closeTimeout   = null)
        {
            if (string.IsNullOrWhiteSpace(project))
            {
                throw new ArgumentNullException("Must provide a project");
            }
            if (string.IsNullOrWhiteSpace(token))
            {
                throw new ArgumentNullException("Must provide a token");
            }
            if (string.IsNullOrWhiteSpace(host))
            {
                host = "relay.signalwire.com";
            }

            mHost        = host;
            mProjectID   = project;
            mToken       = token;
            mCertificate = certificate;

            string authentication = null;

            if (!jwt)
            {
                authentication = CreateAuthentication(project, token);
            }
            else
            {
                authentication = CreateJWTAuthentication(project, token);
            }

            UpstreamSession.SessionOptions options = new UpstreamSession.SessionOptions()
            {
                Bootstrap                = new Uri("wss://" + host),
                Authentication           = authentication,
                Agent                    = agent,
                UncertifiedConnectParams = uncertifiedConnectParams
            };
            if (connectDelay.HasValue)
            {
                options.ConnectDelay = connectDelay.Value;
            }
            if (connectTimeout.HasValue)
            {
                options.ConnectTimeout = connectTimeout.Value;
            }
            if (closeTimeout.HasValue)
            {
                options.CloseTimeout = closeTimeout.Value;
            }
            if (!string.IsNullOrWhiteSpace(certificate))
            {
                options.ClientCertificate = certificate;
            }

            Session = new UpstreamSession(options);

            mSignalwireAPI = new SignalwireAPI(this);
            mCallingAPI    = new CallingAPI(mSignalwireAPI);
            mTaskingAPI    = new TaskingAPI(mSignalwireAPI);
            mMessagingAPI  = new MessagingAPI(mSignalwireAPI);
            mTestingAPI    = new TestingAPI(mSignalwireAPI);

            Session.OnReady += s =>
            {
                if (s.Options.UncertifiedConnectParams?.Protocol != null)
                {
                    // A little bit hacky, but this ensures the protocol is propagated correctly to where it's needed further down the road, and that we register a handler for events
                    mSignalwireAPI.Protocol = s.Options.UncertifiedConnectParams.Protocol;
                    Session.RegisterSubscriptionHandler(s.Options.UncertifiedConnectParams.Protocol, "notifications", (s2, r, p) => mSignalwireAPI.ExecuteNotificationCallback(p));
                }
                OnReady?.Invoke(this);
            };
            Session.OnRestored     += s => OnRestored?.Invoke(this);
            Session.OnDisconnected += s => OnDisconnected?.Invoke(this);
        }
Exemplo n.º 5
0
        public Client(
            string project,
            string token,
            string host        = null,
            string certificate = null,
            string agent       = null,
            ConnectParams.NetworkParam network = null,
            bool jwt = false,
            TimeSpan?connectDelay   = null,
            TimeSpan?connectTimeout = null,
            TimeSpan?closeTimeout   = null)
        {
            if (string.IsNullOrWhiteSpace(project))
            {
                throw new ArgumentNullException("Must provide a project");
            }
            if (string.IsNullOrWhiteSpace(token))
            {
                throw new ArgumentNullException("Must provide a token");
            }
            if (string.IsNullOrWhiteSpace(host))
            {
                host = "relay.signalwire.com";
            }

            mHost        = host;
            mProjectID   = project;
            mToken       = token;
            mCertificate = certificate;

            string authentication = null;

            if (!jwt)
            {
                authentication = CreateAuthentication(project, token);
            }
            else
            {
                authentication = CreateJWTAuthentication(project, token);
            }

            UpstreamSession.SessionOptions options = new UpstreamSession.SessionOptions()
            {
                Bootstrap      = new Uri("wss://" + host),
                Authentication = authentication,
                Agent          = agent,
                NetworkData    = network,
            };
            if (connectDelay.HasValue)
            {
                options.ConnectDelay = connectDelay.Value;
            }
            if (connectTimeout.HasValue)
            {
                options.ConnectTimeout = connectTimeout.Value;
            }
            if (closeTimeout.HasValue)
            {
                options.CloseTimeout = closeTimeout.Value;
            }
            if (!string.IsNullOrWhiteSpace(certificate))
            {
                options.ClientCertificate = certificate;
            }

            Session = new UpstreamSession(options);

            Session.OnReady        += s => OnReady?.Invoke(this);
            Session.OnRestored     += s => OnRestored?.Invoke(this);
            Session.OnDisconnected += s => OnDisconnected?.Invoke(this);

            mSignalwireAPI = new SignalwireAPI(this);
            mCallingAPI    = new CallingAPI(mSignalwireAPI);
            mTaskingAPI    = new TaskingAPI(mSignalwireAPI);
            mMessagingAPI  = new MessagingAPI(mSignalwireAPI);
        }