/// <summary> /// Start game server. /// <paramref name="period">Span between ticks.</paramref> /// </summary> public void Run(int period = DefaultPeriod, bool block = true) { RpcServer.Bind(20170).Run().ContinueWith(s => Logger.Info("Rpc server start ok.")); Logger.Info("SimCivil loop start running."); var token = new CancellationTokenSource(); Task.Factory.StartNew( () => GameLoop(period, token.Token), token.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default) // ReSharper disable once MethodSupportsCancellation .ContinueWith(t => Logger.Info("SimCivil stop loop.")); // ReSharper disable once LoopVariableIsNeverChangedInsideLoop while (block) { switch (Console.ReadKey().Key) { case ConsoleKey.Escape: token.Cancel(); Logger.Info("keyboard exit requested"); return; } } }
static async Task Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; IClusterClient client = new ClientBuilder().UseLocalhostClustering().Build(); await client.Connect(); var container = LoadConfiguration(); container.RegisterInstance(client.ServiceProvider.GetService <IGrainFactory>()); RpcServer server = new RpcServer(container.Build()) { #if DEBUG Debug = true #endif }; await server.Bind(20170).Run(); server.Container.Resolve <OrleansChunkViewSynchronizer>().StartSync(server); await PrepareTest(client); Console.ReadKey(); }
static void Main(string[] args) { GC.AddMemoryPressure(55 * 1024 * 1024); var threadPoolSize = 20; ThreadPool.SetMaxThreads(threadPoolSize, threadPoolSize); ThreadPool.SetMinThreads(threadPoolSize, threadPoolSize); WriteMessage(string.Format("thread pool size:{0}", threadPoolSize)); LogAgent.LogAction = (level, message, ex) => { if (level != LogLevel.Error) { return; } WriteMessage(message); if (ex != null) { WriteMessage(ex.Message); } }; int port = 7777; _rpcServer = new RpcServer(); _rpcServer.Bind(IPAddress.Any, port); Task.Factory.StartNew(() => { try { _rpcServer.Start <CustomMessageProcessor>(); WriteMessage(string.Format("server started,port:{0}", port)); } catch (Exception ex) { _rpcServer = null; WriteMessage("server start failed"); } }, TaskCreationOptions.LongRunning); while (true) { if (Console.ReadLine() == "exit") { break; } } }
public ServerFixture() { var builder = new ContainerBuilder(); builder.UseRpcSession(); builder.RegisterRpcProvider <TestServiceA, ITestServiceA>().InstancePerChannel(); builder.RegisterRpcProvider <TestServiceB, ITestServiceB>().SingleInstance(); Server = new RpcServer(builder.Build()) { Debug = true }; Server.Bind(9999); Server.Run().Wait(); }
public async Task Run(IServiceCollection services) { ContainerBuilder container = ConfigureRpc(services); container.RegisterInstance(Client.ServiceProvider.GetService <IGrainFactory>()); Server = new RpcServer(container.Build()) { #if DEBUG Debug = true #endif }; await Server.Bind(20170).Run(); Server.Container.Resolve <OrleansChunkViewSynchronizer>().StartSync(Server); }
public ServerFixture() { var services = new ServiceCollection(); services.AddLogging(lb => { lb.AddConsole(); }); var builder = new ContainerBuilder(); builder.Populate(services); builder.UseRpcSession(); builder.RegisterRpcProvider <TestServiceA, ITestServiceA>().InstancePerChannel(); builder.RegisterRpcProvider <TestServiceB, ITestServiceB>().SingleInstance(); var container = builder.Build(); Server = new RpcServer(container) { Debug = true }; Server.Bind(9999); Server.Run().Wait(); }