public bool StartUp(ServerConfig config = null, params Autofac.Module[] modules) { var setupOk = ObjectHost.Setup( new Module[] { new RpcNetModule(), new ServerModule() }.Concat(modules)); if (setupOk) { using (var scope = ObjectHost.Host.BeginLifetimeScope()) { config = config ?? new ServerConfig(); acceptor = new AsyncSocketAcceptor(config.MaxConnections); acceptor.FilterChain.AddLast("session-metrics", new SessionMetricsFilter()); acceptor.FilterChain.AddLast("logger", new LoggingFilter()); acceptor.FilterChain.AddLast("codec", new ProtocolCodecFilter(new MessageCodecFactory())); filterTypes.ForEach(type => filters.Add(scope.Resolve(type) as AbstractFilter)); filters.ForEach(filter => acceptor.FilterChain.AddLast(filter.Name, filter)); acceptor.FilterChain.AddLast("exceptionCounter", scope.Resolve <ExceptionCounterFilter>()); acceptor.FilterChain.AddLast("session-abnormal", scope.Resolve <SessionAbnormalFilter>()); acceptor.Handler = scope.Resolve <CommandHandler>(); acceptor.SessionConfig.ReadBufferSize = config.ReadBufferSize; acceptor.SessionConfig.SendBufferSize = config.SendBufferSize; acceptor.SessionConfig.ReaderIdleTime = config.ReaderIdleTime; acceptor.SessionConfig.WriterIdleTime = config.WriterIdleTime; acceptor.SessionConfig.WriteTimeout = config.WriteTimeout; acceptor.SessionConfig.KeepAlive = config.KeepAlive; acceptor.Bind(EndPoint); } } return(setupOk); }
static void Main() { bool ret; Mutex mutex = new Mutex(true, Application.ProductName, out ret); if (ret) { ObjectHost.Setup(new Module[] { new WinformModule(), new LocalApiMockModule() }); PresenterBinder.Factory = new AutofacPresenterFactory(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frmLogin loginForm = new frmLogin(); if (loginForm.ShowDialog() == DialogResult.OK) { Application.Run(new frmMain()); } mutex.ReleaseMutex(); } else { MessageBox.Show(null, "有一个和本程序相同的应用程序正在运行,请不要同时运行多个本程序。\n\n这个程序即将退出。", Constants.PRODUCT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } }
public bool StartUp(params Autofac.Module[] modules) { return(ObjectHost.Setup( new Module[] { new RpcSerialModule() }.Concat(modules))); }
static void Main(string[] args) { ConfigurationManager.AppSettings.Set("PortName", "COM3"); ObjectHost.Setup(new Module[] { new DaemonModule(), new MockModule() }); //RunCheckInQueryInstructionWithNoReply(); //RunAddrAssignInstruction(); RunSizeAllocInstruction(); Console.ReadLine(); }
public bool Init(params Autofac.Module[] modules) { return(ObjectHost.Setup( new Module[] { new RpcNetModule(), new ClientModule() }.Concat(modules))); }
public void SetUp() { ObjectHost.Setup(new Module[] { new RepositoryModule() }); }