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); }
public IControlledWampConnection <TMessage> Activate <TMessage>(IWampBinding <TMessage> binding) { IControlledWampConnection <TMessage> connection = mConnectionActivator.Activate(binding); ScheduledWampConnection <TMessage> result = new ScheduledWampConnection <TMessage>(connection, mScheduler); return(result); }
public ScheduledWampConnection(IControlledWampConnection <TMessage> connection, IScheduler scheduler) { mConnection = connection; mScheduler = scheduler; mMessageArrived = GetEventHandler <WampMessageArrivedEventArgs <TMessage> > (x => mConnection.MessageArrived += x, x => mConnection.MessageArrived -= x); mConnectionOpen = GetEventHandler (x => mConnection.ConnectionOpen += x, x => mConnection.ConnectionOpen -= x); mConnectionClosed = GetEventHandler (x => mConnection.ConnectionClosed += x, x => mConnection.ConnectionClosed -= x); mConnectionError = GetEventHandler <WampConnectionErrorEventArgs> (x => mConnection.ConnectionError += x, x => mConnection.ConnectionError -= x); }
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); }
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")); }
public IWampChannel CreateChannel<TMessage>(string realm, IControlledWampConnection<TMessage> connection, IWampBinding<TMessage> binding, IWampClientAuthenticator authenticator) { WampChannelBuilder<TMessage> builder = GetChannelBuilder(binding); WampChannel<TMessage> channel = builder.CreateChannel(realm, connection, authenticator); return channel; }
public IWampChannel <TMessage> CreateChannel(IControlledWampConnection <TMessage> connection) { return(new WampChannel <TMessage>(connection, mRpcClientFactory, mPubSubClientFactory, mServerProxyBuilder, mWampAuxiliaryClientFactory)); }
public void Send(WampMessage <object> message) { IControlledWampConnection <TMessage> connection = mConnection; if (connection != null) { connection.Send(message); } }
public void Dispose() { IControlledWampConnection <TMessage> connection = mConnection; if (connection != null) { connection.Dispose(); } }
public void Connect() { if (mConnection == null) { mConnection = SetupConnection(); } mConnection.Connect(); }
private void OnNewConnection(IWampConnection <TMessage> connection) { mSubject.OnNext(connection); // Yuck IControlledWampConnection <TMessage> casted = connection as IControlledWampConnection <TMessage>; casted.Connect(); }
private void DestroyConnection() { mConnection.ConnectionOpen -= OnConnectionOpen; mConnection.ConnectionClosed -= OnConnectionClosed; mConnection.ConnectionError -= OnConnectionError; mConnection.MessageArrived -= OnMessageArrived; mConnection.Dispose(); mConnection = null; }
public WampChannel <TMessage> CreateChannel(string realm, IControlledWampConnection <TMessage> connection) { var wampRealmProxyFactory = new WampRealmProxyFactory(this, realm, connection); WampClient <TMessage> client = new WampClient <TMessage>(wampRealmProxyFactory); return(new WampChannel <TMessage>(connection, client)); }
public IWampChannel CreateClientConnection(string realm, IScheduler scheduler) { IControlledWampConnection <object> connection = mInternalTransport.CreateClientConnection(mInternalBinding, scheduler); IWampChannel result = mChannelFactory.CreateChannel(realm, connection, mInternalBinding); return(result); }
public WampChannel(IControlledWampConnection <TMessage> connection, WampClient <TMessage> client) { mConnection = connection; mConnection.ConnectionOpen += OnConnectionOpen; mConnection.ConnectionError += OnConnectionError; mConnection.ConnectionClosed += OnConnectionClosed; mClient = client; mServer = client.Realm.Proxy; }
private IControlledWampConnection <TMessage> SetupConnection() { IControlledWampConnection <TMessage> result = mFactory(); result.ConnectionOpen += OnConnectionOpen; result.ConnectionClosed += OnConnectionClosed; result.ConnectionError += OnConnectionError; result.MessageArrived += OnMessageArrived; return(result); }
public void Close() { lock (mLock) { if (mConnection != null) { mConnection.Dispose(); mConnection = null; } } }
public void OnNext(IWampConnection <TMessage> value) { mSubject.OnNext(value); // Yuck IControlledWampConnection <TMessage> casted = value as IControlledWampConnection <TMessage>; if (casted != null) { casted.Connect(); } }
public WampChannel(IControlledWampConnection <TMessage> connection, IWampRpcClientFactory <TMessage> rpcClientFactory, IWampPubSubClientFactory <TMessage> pubSubClientFactory, WampServerProxyBuilder <TMessage, IWampClient <TMessage>, IWampServer> serverProxyBuilder, IWampAuxiliaryClientFactory <TMessage> connectionMonitorFactory) { mConnection = connection; mRpcClientFactory = rpcClientFactory; mPubSubClientFactory = pubSubClientFactory; mServerProxyBuilder = serverProxyBuilder; mConnectionMonitor = connectionMonitorFactory.CreateMonitor(connection); }