public SingleArena(ArenaHost arena_host, List <Player> buffer, CreateArenaResult result) { this.arena_host = arena_host; players = buffer; channel = new Channel(result.PrivateConnectionStr, ChannelCredentials.Insecure); //TODO: SSL, Compression, OAuth client = new ArenaServicePrivateClient(channel); Task.Run(subscribe_and_handle); }
public override async Task <CreateArenaResult> CreateArena(CreateArenaAttempt request, ServerCallContext context) { var result = new CreateArenaResult(); var args = new StringBuilder(); args.Append("-executeMethod SingleArenaServerController.Run "); var private_port = port_allocator.Allocate(); if (!private_port.HasValue) { Log.Warning("Could not allocate a port from the port allocator"); result.Success = false; return(result); } var public_port = port_allocator.Allocate(); if (!public_port.HasValue) { Log.Warning("Could not allocate a port from the port allocator"); result.Success = false; return(result); } args.Append("-private_port="); args.Append(private_port.Value); args.Append(" "); args.Append("-public_port="); args.Append(public_port.Value); args.Append(" "); if (!show_arena_windows) { args.Append("-batchmode -nographics "); } var process = new Process(); process.StartInfo = new ProcessStartInfo { FileName = invoke_unity_file, Arguments = args.ToString() }; if (!processes.AddIfCountIsLessThan(process, max_arena_count)) { result.Success = false; return(result); } process.EnableRaisingEvents = true; process.Exited += on_process_exited; process.Start(); await Task.Delay(process_startup_delay_sec * 1000); if (process.HasExited) { Log.Warning("Could not start arena process properly"); result.Success = false; return(result); } result.FreeArenaCount = max_arena_count - processes.Count(); result.PrivateConnectionStr = self_url + ":" + private_port.Value; result.PublicConnectionStr = self_url + ":" + public_port.Value; return(result); }