示例#1
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 64;
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;

            #region Launch silo in separate AppDomain

            var dataConnectionString     = RoleEnvironment.GetConfigurationSettingValue("DataConnectionString");
            var orleansSiloConfiguration = File.ReadAllText("OrleansConfiguration.xml").Replace(
                "XXXDataConnectionStringValueXXX", dataConnectionString);
            this.siloHost = new SiloHost();
            this.siloHost.StartLobbyServiceSiloAppDomain(orleansSiloConfiguration);

            #endregion

            Trace.TraceInformation("LobbyServiceInstanceId " + this.SharedSettings.InstanceId);
            Trace.TraceInformation("Settings.IPEndPoint    " + this.LobbyServiceSettings.IPEndPoint.ToString());

            if (!OrleansAzureClient.IsInitialized)
            {
                OrleansAzureClient.Initialize("ClientConfiguration.xml");
            }

            var server = new AsyncServerHost(this.LobbyServiceSettings.IPEndPoint);
            this.lobbyServerImpl = cc.GetExportedValue <LobbyServerImpl>();
            this.lobbyTask       = server.Start(lobbyServerImpl, cts.Token);

            return(true);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.Title = "Backend.GameServer";

            if (args.Length != 4)
            {
                Console.Error.WriteLine("Provide ip address (such as 127.0.0.1), TCP port and secret key (base64) as command line args");
                return;
            }

            var argIpAddress    = args[0];
            var argPortNumber   = args[1];
            var argSecretKey    = args[2];
            var argGameServerId = args[3];


            IPAddress address;

            if (!IPAddress.TryParse(argIpAddress, out address))
            {
                Console.Error.WriteLine("\"{0}\" is not a valid IP address", args[0]);
                return;
            }
            int port;

            if (!int.TryParse(argPortNumber, out port))
            {
                Console.Error.WriteLine("\"{0}\" is not a valid TCP port", args[1]);
                return;
            }
            var ipEndPoint = new IPEndPoint(address, port);

            byte[] secretKey    = Convert.FromBase64String(argSecretKey);
            var    gameServerID = new GameServerID {
                ID = Guid.Parse(argGameServerId)
            };

            Console.WriteLine("Listen on {0}", ipEndPoint);

            var cts    = new CancellationTokenSource();
            var server = new AsyncServerHost(ipEndPoint);

            var  gameServerImpl = new GameServerImpl(gameServerID, secretKey);
            Task t = server.Start(gameServerImpl, cts.Token);

            Console.WriteLine("Launched game server process on {0}", ipEndPoint);
            t.Wait();
        }
        static void Main(string[] args)
        {
            Console.Title = "Backend.LobbyServer";

            var cts = new CancellationTokenSource();

            var compositionContainer = new CompositionContainer(new AggregateCatalog(
                                                                    new AssemblyCatalog(typeof(DevelopmentSettingsProvider).Assembly)
                                                                    ));
            var settings = compositionContainer.GetExportedValue <LobbyServiceSettings>();

            var  lobbyServerImpl = compositionContainer.GetExportedValue <LobbyServerImpl>();
            var  server          = new AsyncServerHost(settings.IPEndPoint);
            Task t = server.Start(lobbyServerImpl, cts.Token);

            Console.WriteLine("Loby server launched");
            Console.ReadLine();
            cts.Cancel();
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.Title = "Backend.ProxyServer";

            if (args.Length != 2)
            {
                Console.Error.WriteLine("Need ipaddress and port number for proxy.");
                return;
            }

            var argIpAddress  = args[0];
            var argPortNumber = args[1];

            IPAddress defaultForwarderAddress = IPAddress.Parse(argIpAddress);
            int       portNumber = int.Parse(argPortNumber);

            IPEndPoint proxyEndpoint = new IPEndPoint(defaultForwarderAddress, portNumber);

            CancellationTokenSource cts             = new CancellationTokenSource();
            AsyncServerHost         proxyServerHost = new AsyncServerHost(proxyEndpoint);
            Task proxyTask = proxyServerHost.StartFunctional(async(client, ct) => await ProxyConnection.ProxyLogic(client, cts, defaultForwarderAddress), cts.Token);

            Task.Factory.StartNew(async() =>
            {
                var ct = cts.Token;

                Trace.TraceInformation("Cloud.GameServerHost.WorkerRole entry point called", "Information");

                while (!ct.IsCancellationRequested)
                {
                    await Task.Delay(TimeSpan.FromSeconds(10));

                    Trace.TraceInformation("Working", "Information");
                }
            }).Unwrap().Wait();
        }