示例#1
0
 private static IHostBuilder CreateHostBuilder(string[] args) =>
 Host.CreateDefaultBuilder(args)
 .ConfigureWebHostDefaults(webBuilder =>
 {
     webBuilder.ConfigureKestrel(options =>
     {
         var grpcPort = Configuration.Get().GetSection("GrpcServer").GetValue <int>("port");
         // Setup a HTTP/2 endpoint without TLS.
         options.ListenLocalhost(grpcPort, o => o.Protocols =
                                     HttpProtocols.Http2);
     });
     webBuilder.UseStartup <Startup>();
 });
示例#2
0
        public void Start()
        {
            NetPeerConfiguration config = new NetPeerConfiguration("MulTUNG");

            config.Port         = (int)Configuration.Get <long>("ServerPort", 5678);
            config.LocalAddress = IPAddress.Parse(Configuration.Get("LocalServerIP", "127.0.0.1"));
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);

            Server = new NetServer(config);
            Server.Start();

            Network.IsServer = true;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                NetIncomingMessage msg;
                while (Server != null)
                {
                    msg = Server.WaitMessage(int.MaxValue);

                    if (msg == null)
                    {
                        continue;
                    }

                    HandleMessage(msg);

                    Server.Recycle(msg);
                }
            });

            World.AddNetObjects();
            World.LoadCircuitState();

            Network.StartPositionUpdateThread(Constants.PositionUpdateInterval);

            Log.WriteLine("Listening on port " + config.Port);
        }
示例#3
0
 public NetworkServer()
 {
     Instance          = this;
     MaxUsernameLength = (int)Configuration.Get <long>("MaxUsernameLength", 15);
 }