/// <summary> /// Creates a new instance of <see cref="WampRpcClientHandler{TMessage}"/>. /// </summary> public WampRpcClientHandler(IWampServerProxyFactory <TMessage> serverProxyFactory, IWampConnection <TMessage> connection, IWampFormatter <TMessage> formatter) { mFormatter = formatter; mServerProxy = serverProxyFactory.Create(new RpcWampClient(this), connection); connection.ConnectionClosed += Connection_ConnectionClosed; connection.ConnectionError += Connection_ConnectionError; }
private IWampIncomingMessageHandler <JToken, IWampClient> GetHandler(IWampServer <JToken> wampServer) { IWampIncomingMessageHandler <JToken, IWampClient> handler = new WampIncomingMessageHandler <JToken, IWampClient> (new WampRequestMapper <JToken>(wampServer.GetType(), mFormatter), new WampMethodBuilder <JToken, IWampClient>(wampServer, mFormatter)); return(handler); }
private IWampIncomingMessageHandler<JToken, IWampClient> GetHandler(IWampServer<JToken> wampServer) { IWampIncomingMessageHandler<JToken, IWampClient> handler = new WampIncomingMessageHandler<JToken, IWampClient> (new WampRequestMapper<JToken>(wampServer.GetType(), mFormatter), new WampMethodBuilder<JToken, IWampClient>(wampServer, mFormatter)); return handler; }
public WampHost(IWampServerBuilder <TMessage> serverBuilder, IWampConnectionListener <TMessage> connectionListener, IWampFormatter <TMessage> formatter) { mFormatter = formatter; mMetadataCatalog = new WampRpcMetadataCatalog(); mTopicContainer = new WampTopicContainer <TMessage>(); mServer = serverBuilder.Build(formatter, mMetadataCatalog, mTopicContainer); mListener = GetWampListener(connectionListener, formatter, mServer); }
public void Setup() { _connections = new List <Mock <IWampConnection> >(); _commsMock = new Mock <IWampCommsHandler>(); _commsMock.Setup(x => x.Start(It.IsAny <Action <IWampConnection> >())) .Callback <Action <IWampConnection> >(x => { var c = CreateMockConnection(); _connections.Add(c); x(c.Object); }); _wampServer = new WampServer(_commsMock.Object); }
public WampBindedRealm(IWampHostedRealm realm, IWampRouterBuilder routerBuilder, IWampSessionServer <TMessage> session, IWampBinding <TMessage> binding, IWampEventSerializer eventSerializer) { mRealm = realm; mRealmGate = realm as IWampRealmGate; IWampDealer <TMessage> dealer = routerBuilder.CreateDealerHandler(realm, binding); IWampBroker <TMessage> broker = routerBuilder.CreateBrokerHandler(realm, binding, eventSerializer); mServer = routerBuilder.CreateServer(session, dealer, broker); }
public void CallServer_And_Receive_Call_Result() { MockListener <JToken> mockListener = new MockListener <JToken>(); Mock <IWampServer <JToken> > serverMock = new Mock <IWampServer <JToken> >(); serverMock.Setup(x => x.Call(It.IsAny <IWampClient>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <JToken[]>())) .Callback((IWampClient clientParameter, string callId, string procUrl, JToken[] arguments) => { clientParameter.CallResult(callId, new { stuff = "cool" }); }); WampListener <JToken> listener = GetListener(mockListener, serverMock.Object); Mock <IWampClient <JToken> > clientMock = new Mock <IWampClient <JToken> >(); MockConnection <JToken> connection = new MockConnection <JToken>(mFormatter); IWampServer client = GetClient(connection.SideAToSideB, clientMock.Object); listener.Start(); mockListener.OnNext(connection.SideBToSideA); clientMock.Verify(x => x.Welcome(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>())); Mock <IWampClient> userClientMock = new Mock <IWampClient>(); client.Call(userClientMock.Object, "a123123", "Test", new { name = "Jack" }); serverMock.Verify(x => x.Call(It.IsAny <IWampClient>(), "a123123", "Test", It.IsAny <JToken[]>())); clientMock.Verify(x => x.CallResult("a123123", It.Is((JToken result) => result.Value <string>("stuff") == "cool"))); }
public MockWampServerProxyFactory(IWampServer server) { mServer = server; }
private static WampListener <TMessage> GetWampListener(IWampConnectionListener <TMessage> connectionListener, IWampFormatter <TMessage> formatter, IWampServer <TMessage> server) { IWampClientBuilderFactory <TMessage, IWampClient> clientBuilderFactory = GetWampClientBuilder(formatter); IWampClientContainer <TMessage, IWampClient> clientContainer = new WampClientContainer <TMessage>(clientBuilderFactory); IWampRequestMapper <TMessage> requestMapper = new WampRequestMapper <TMessage>(server.GetType(), formatter); WampMethodBuilder <TMessage, IWampClient> methodBuilder = new WampMethodBuilder <TMessage, IWampClient>(server, formatter); IWampIncomingMessageHandler <TMessage, IWampClient> wampIncomingMessageHandler = new WampIncomingMessageHandler <TMessage, IWampClient> (requestMapper, methodBuilder); return(new WampListener <TMessage> (connectionListener, wampIncomingMessageHandler, clientContainer)); }
/// <summary> /// Initializes a new instance of <see cref="WampPubSubSubject{TMessage,TEvent}"/>. /// </summary> /// <param name="topicUri">The topic uri of the current topic.</param> /// <param name="serverProxyFactory">The server proxy factory used to get /// callbacks from the server.</param> /// <param name="connection">The underlying connection this subject uses /// in order to send/receive messages.</param> /// <param name="formatter">The formatter used in order to serialize/deserialize /// the messages sent.</param> public WampPubSubSubject(string topicUri, IWampServerProxyFactory <TMessage> serverProxyFactory, IWampConnection <TMessage> connection, IWampFormatter <TMessage> formatter) { mTopicUri = topicUri; mFormatter = formatter; mServerProxy = serverProxyFactory.Create(new WampPubSubClient(this), connection); }