Ejemplo n.º 1
0
        public void NoAuthenticationThrowsException()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            Task <string> result =
                channel.GetRpcProxy <ISampleAsync>()
                .Hello("Foobar");

            AggregateException   aggregateException = result.Exception;
            Exception            exception          = aggregateException.InnerException;
            WampRpcCallException casted             = exception as WampRpcCallException;

            Assert.IsNotNull(casted);
        }
Ejemplo n.º 2
0
        public void AuthenticationFailure()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            IWampCraProcedures proceduresProxy = channel.GetRpcProxy <IWampCraProcedures>();

            WampRpcCallException callException =
                Assert.Throws <WampRpcCallException>
                    (() => proceduresProxy.Authenticate(formatter, "foobar", null, "secret2"));
        }
Ejemplo n.º 3
0
        public void AuthenticationSuccess()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            channel.GetRpcProxy <IWampCraProcedures>().
            Authenticate(formatter, "foobar", null, "secret");

            string result = channel.GetRpcProxy <ISample>()
                            .Hello("Foobar");

            Assert.That(result, Is.Not.Null.Or.Empty);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Indicates that the user wants to connect to a given realm.
 /// </summary>
 /// <param name="realm">The requested realm to connect to</param>
 public static ChannelFactorySyntax.IRealmSyntax ConnectToRealm(this IWampChannelFactory factory, string realm)
 {
     return(new ChannelState()
     {
         ChannelFactory = factory,
         Realm = realm
     });
 }
 public static IWampChannel <JToken> CreateChannel(this IWampChannelFactory <JToken> factory,
                                                   WebSocket socket)
 {
     return(factory.CreateChannel(new WebSocket4NetTextConnection <JToken>(socket, new Wamp1Binding())));
 }
 public static IWampChannel <TMessage> CreateChannel <TMessage>(this IWampChannelFactory <TMessage> factory, string address, IWampTextMessageParser <TMessage> parser)
 {
     return(factory.CreateChannel(new WebSocket4NetTextConnection <TMessage>(address,
                                                                             new Wamp1Binding <TMessage>(parser, factory.Formatter))));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public PoloniexExchangeMonitor(IWampChannelFactory wampChannelFactory)
 {
     _wampChannelFactory = Preconditions.CheckNotNull(wampChannelFactory);
 }
Ejemplo n.º 8
0
 public static IWampChannel <TMessage> CreateChannel <TMessage>(this IWampChannelFactory <TMessage> factory, string address, IWampTextMessageParser <TMessage> parser)
 {
     return(factory.CreateChannel(address, parser, (Action <SecurityOption>)null));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PoloniexTickerService(IWampChannelFactory wampChannelFactory)
 {
     _wampChannelFactory = Preconditions.CheckNotNull(wampChannelFactory);
 }