Skip to content

Client Providers (Client Side Example)

Ali Yousefi edited this page Feb 26, 2019 · 10 revisions

After create your server side project you must create your client side project for connect to your server.

In signalgo new version all services will generate automatically for client side with visual studio extension,so you can use you services very easy.

1. Example for ServerServices (duplex rel-time services):

                //your client connector that will be connect to your server
                ClientProvider provider = new ClientProvider();
                //connect to your server must have full address that your server is listen
                provider.Connect("http://localhost:1132/SignalGoTestService");
                //register your service interfacce for client
                //AuthenticationService is you service class name in server side that generated in client side with the namespace you add in signal visual studio extension

                ServicesNameSpace.Interfaces.IAuthenticationService authenticationService = provider.RegisterServerService<ServicesNameSpace.ServerServices.AuthenticationService>();
                //call server method and return value from your server to client
                var result = authenticationService.HelloWorld("ali");
                //for async call
                var result2 = await authenticationService.HelloWorldAsync("ali");
                //print your result to console
                Console.WriteLine(result.Item1);

2. Example for HttpServices:

                ServicesNameSpace.Interfaces.IAuthenticationService authenticationService = new ServicesNameSpace.HttpServices.AuthenticationService("http://localhost:1132",new SignalGo.Client.HttpClient() {
 Encoding= System.Text.Encoding.UTF8 });
                //call server method and return value from your server to client
                var result = authenticationService.HelloWorld("ali");
                //for async call
                var result2 = await authenticationService.HelloWorldAsync("ali");
                //print your result to console
                Console.WriteLine(result.Item1);

Clone this wiki locally