Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //create your server provider
            ServerProvider serverProvider = new ServerProvider();

            //register your server service
            serverProvider.RegisterServerService <HelloWorldService>();
            serverProvider.RegisterServerService <TestStreamService>();
            serverProvider.RegisterClientService <IHelloCallbackClientService>();
            //handle cross origin
            serverProvider.ProviderSetting.HttpSetting.HandleCrossOriginAccess = true;
            //serverProvider.Start("http://localhost:6235/any");
            //websocket for duplex clients
            WebSocketOptions webSocketOptions = new WebSocketOptions()
            {
                KeepAliveInterval = TimeSpan.FromSeconds(120),
                ReceiveBufferSize = 4 * 1024,
            };

            app.UseWebSockets(webSocketOptions);

            //add signalgo middlleware
            app.UseMiddleware <SignalGoNetCoreMiddleware>(serverProvider);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ServerProvider serverProvider = new ServerProvider();

            serverProvider.RegisterServerService <Services.HelloWorldService>();
            serverProvider.RegisterServerService <Services.TestStreamService>();
            serverProvider.RegisterClientService <ClientServices.IHelloCallbackClientService>();
            //to handle cross origin errors
            serverProvider.ProviderSetting.HttpSetting.HandleCrossOriginAccess = true;
            serverProvider.Start("http://localhost:9674/SignalGo");
            Console.WriteLine("server started");
            Console.ReadKey();
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            ServerProvider serverProvider = new ServerProvider();

            serverProvider.RegisterServerService <AuthenticationService>();
            serverProvider.RegisterServerService <BookService>();
            serverProvider.ProviderSetting.IsEnabledDataExchanger = false;
            serverProvider.Start("http://localhost:6452/SignalGoTest/any");

            SignalGoBotManager signalGoBotManager = new SignalGoBotManager();

            signalGoBotManager.Start("your telegram bot token here", serverProvider);
            Console.WriteLine("server started successfuly call your services with telegram bot or http request, example http://localhost:6452/Book/GetListOfBook");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            //create your server provider
            ServerProvider serverProvider = new ServerProvider();

            //register your server service
            serverProvider.RegisterServerService <HelloWorldService>();
            //register client service
            serverProvider.RegisterClientService <IHelloCallbackClientService>();
            //handle cross origin
            serverProvider.ProviderSetting.HttpSetting.HandleCrossOriginAccess = true;
            //add signalgo middlleware
            app.Use <SignalGo.Server.Owin.SignalGoOwinMiddleware>(serverProvider);

            HttpConfiguration config = new HttpConfiguration();

            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);
            config.Routes.MapHttpRoute(
                "DefaultApi", // Route name
                "", "http://localhost:10012/HellowWorld/Hello");
            app.UseWebApi(config);
        }
Exemplo n.º 5
0
        private static void Main(string[] args)
        {
            ServerProvider serverProvider = new ServerProvider();

            serverProvider.RegisterServerService <UserService>();
            serverProvider.Start("http://localhost:6525/any");
            Console.WriteLine("server started");
            Console.ReadKey();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            ServerProvider serverProvider = new ServerProvider();

            serverProvider.RegisterServerService <ChatService>();
            serverProvider.RegisterClientService <IClientChatService>();
            serverProvider.Start("http://localhost:6262/any");
            Console.WriteLine("server started");
            Console.ReadLine();
        }
Exemplo n.º 7
0
        public MainWindow()
        {
            This = this;
            InitializeComponent();
            mainframe.Navigate(new FirstPage());
            Closing += MainWindow_Closing;

            ServerProvider serverProvider = new ServerProvider();

            serverProvider.RegisterServerService <ServerManagerService>();
            serverProvider.Start("http://localhost:5468/ServerManager/SignalGo");
        }
Exemplo n.º 8
0
        private static void Main(string[] args)
        {
            try
            {
                ServerProvider serverProvider = new ServerProvider();
                serverProvider.RegisterServerService <FullHttpSupportService>();
                serverProvider.Start("http://localhost:8080/TestService/any");

                Console.WriteLine("seerver started");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.ReadLine();
        }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            serverProvider.RegisterServerService <SignalGoServices.HelloWorldService>();
            //to handle cross origin errors
            serverProvider.ProviderSetting.HttpSetting.HandleCrossOriginAccess = true;
            serverProvider.AddAssemblyToSkipServiceReferences(typeof(Shared.Models.UserInfo).Assembly);
            app.UseResponseCompression();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}");
            });
            app.UseMiddleware <SignalGo.Server.Owin.SignalGoNetCoreMiddleware>(serverProvider);
            app.UseBlazor <Client.Startup>();
        }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            //create instace of server provider
            ServerProvider serverProvider = new ServerProvider();

            //register your service class
            serverProvider.RegisterServerService <ExampleService>();

            //customize your validation resutl to client
            serverProvider.ValidationResultHandlingFunction = (validations, service, method) =>
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (BaseValidationRuleInfoAttribute item in validations)
                {
                    stringBuilder.AppendLine(BaseValidationRuleInfoAttribute.GetErrorValue(item).ToString());
                }
                return(stringBuilder.ToString());
            };

            //start server with port 4521
            serverProvider.Start("http://localhost:4521/any");

            InitializeValidationRules(serverProvider);


            //example start in your browser

            //invalid login
            StartProcess("http://localhost:4521/Example/Login?userName=&password="******"http://localhost:4521/Example/Login?userName=test&password=testpass");
            //valid addcontact
            StartProcess("http://localhost:4521/Example/AddContact?contact=" + Uri.EscapeDataString("{\"Name\":\"test\"}"));
            //invalid addcontact
            StartProcess("http://localhost:4521/Example/AddContact?contact={}");
            Console.WriteLine("Server started!");
            Console.ReadLine();
        }
Exemplo n.º 11
0
        public static void Initialize()
        {
            if (server == null)
            {
                server = new SignalGo.Server.ServiceManager.ServerProvider();
                server.RegisterServerService <Models.TestServerStreamModel>();
                server.RegisterServerService <Models.TestServerModel>();
                server.RegisterServerService <Models.AuthenticationService>();
                server.RegisterClientService <Models.ITestClientServiceModel>();
                server.Start("http://localhost:1132/SignalGoTestService");
                server.ErrorHandlingFunction = (ex, serviceType, method, client) =>
                {
                    return(new MessageContract()
                    {
                        IsSuccess = false, Message = ex.ToString()
                    });
                };
                server.ValidationResultHandlingFunction = (errors, service, method) =>
                {
                    List <Models.ValidationRule> result = new List <Models.ValidationRule>();
                    foreach (BaseValidationRuleAttribute item in errors)
                    {
                        result.Add(new Models.ValidationRule()
                        {
                            Message = item.Message, Name = item.PropertyInfo?.Name
                        });
                    }
                    return(new MessageContract <ArticleInfo>()
                    {
                        IsSuccess = false, Errors = result
                    });
                };
                ////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");
                //var service = provider.RegisterClientServiceInterfaceWrapper<ITestClientServerModel>();

                //try
                //{
                //    var result = service.HelloWorld("ali");
                //    //var result1 = await service.MUL(10, 20);
                //    //var result3 = await service.WhoAmI();
                //    //var result40 = service.Tagh(10, 3);
                //    ////var result41 = service.Tagha(10, 3);
                //    //var result4 = await service.TaghAsync(10, 3);
                //    //var result5 = await service.LongValue();
                //    //var result6 = await service.TimeS(100000000);
                //}
                //catch (Exception ex)
                //{

                //}
                ////register your service interfacce for client
                ////var testServerModel = provider.RegisterClientServiceDynamic<ITestServerModel>();
                ////call server method and return value from your server to client
                ////var result = testServerModel.HelloWorld("ali");
                //provider.Dispose();
                //Thread.Sleep(10000);
                //print your result to console
                //Console.WriteLine(result.Item1);
            }
            //client = new ClientProvider();
            //client.Connect("http://localhost:1132/SignalGoTestService");
        }