Exemple #1
0
        public async Task NotAuthenticatedIntegrationTest()
        {
            WampAuthenticationPlayground playground =
                new WampAuthenticationPlayground
                    (new WampCraUserDbAuthenticationFactory
                        (new MyAuthenticationProvider(),
                        new MyUserDb()));

            SetupHost(playground);

            IWampClientAuthenticator authenticator =
                new WampCraClientAuthenticator(authenticationId: "peter", secret: "SECRET");

            IWampChannel channel =
                playground.CreateNewChannel("realm1", authenticator);

            IWampRealmProxy realmProxy = channel.RealmProxy;

            WampConnectionBrokenException openException = null;

            try
            {
                await channel.Open().ConfigureAwait(false);
            }
            catch (WampConnectionBrokenException ex)
            {
                openException = ex;
            }

            Assert.That(openException, Is.Not.Null);
            Assert.That(openException.CloseType, Is.EqualTo(SessionCloseType.Abort));
            Assert.That(openException.Reason, Is.EqualTo(WampErrors.NotAuthorized));
        }
        public void ConnectionClosed(WampSessionCloseEventArgs eventArgs)
        {
            WampConnectionBrokenException exception =
                new WampConnectionBrokenException(eventArgs);

            SetException(exception);
        }
        private void OnConnectionBroken(object sender, WampSessionCloseEventArgs e)
        {
            Exception exception = new WampConnectionBrokenException(e);

            SetException(exception);

            mDisconnectionTaskCompletionSource = new TaskCompletionSource <Exception>();
            mDisconnectionWaitHandle           = new ManualResetEvent(false);
        }
        private void OnConnectionBroken(object sender, WampSessionCloseEventArgs e)
        {
            Exception exception = new WampConnectionBrokenException(e);

            SetException(exception);
        }