/// <inheritdoc /> public object Connect(Type type, string objectId) { var contractDescription = _contractDescriptionFactory.Create(type); //Send ConnectObjectMessage to ensure that object is hosted var connectObjectMessage = new ConnectMessage(_clientHostAddress, objectId); _outputChannel.SendWithAck(connectObjectMessage); var knownTypes = contractDescription.GetTypes(); var serializer = _serializerFactory.Create(typeof(object), knownTypes); var interceptor = new ClientInterceptor(contractDescription); var proxy = _proxyGenerator.CreateInterfaceProxyWithoutTarget(type, interceptor); var connection = new Connection(objectId, proxy, _eventHandlersRepository, contractDescription, serializer, this, _outputChannel, _clientHostAddress); interceptor.Subscribe(connection); lock (_objectIds) { RemoveDeadObjectIds(); _objectIds.Add(new Tuple <string, WeakReference>(objectId, new WeakReference(proxy))); } return(proxy); }
private void EnsureClientInterceptorBehavior(ServiceEndpoint endpoint) { ClientInterceptor item = endpoint.Behaviors.Find <ClientInterceptor>(); if (item == null) { endpoint.Behaviors.Add(new ClientInterceptor(this)); } }
public TestClient(string grpcHostName, int grpcPort, int metricsPort) { MetricsPort = metricsPort; _metricsServer = new MetricServer(MetricsHostname, MetricsPort); _metricsServer.Start(); _interceptor = new ClientInterceptor(true); var channel = new Channel(grpcHostName, grpcPort, ChannelCredentials.Insecure); _client = new TestService.TestServiceClient( channel.Intercept(_interceptor)); }
public TestClient(string grpcHostName, int grpcPort, int metricsPort) { MetricsPort = metricsPort; ClientInterceptor interceptor = new ClientInterceptor(MetricsHostname, metricsPort) { EnableLatencyMetrics = true }; Channel channel = new Channel(grpcHostName, grpcPort, ChannelCredentials.Insecure); _client = new TestService.TestServiceClient( channel.Intercept(interceptor)); }