Beispiel #1
0
        public ServiceHostRelayProxy(string instanceId, Uri messageHubChannel, IServiceHost svcHost)
        {
            this.InstanceId = InstanceId;

            HubConnection = (new HubConnectionBuilder() as IHubConnectionBuilder)
                            .WithUrl(messageHubChannel)
                            .WithConsoleLogger()
                            .Build();

            // todo: refactor the client invocation method signatures
            HubConnection.On <object>(CX.WorkerMethodName, commandData =>
            {
                if (svcHost != null)
                {
                    var serviceInstance = svcHost.CreateServiceInstance(typeof(TService));
                    serviceInstance.Execute(this, commandData);
                }
            });

            HubConnection.StartAsync().Wait();
        }