private ZApi() { // creating a client services _connection = new ZConnection(); _statsService = new ZStatsService(); _gameFactory = new ZGameFactory(_connection); _injector = new ZInjectorService(); // initializing the static helpers ZConnectionHelper.Initialize(_connection); }
public GameService( IZApi api, App application, ISettingsService settingsService) { _kernel = Resolver.Kernel; _gameFactory = api.GameFactory; _settingsService = settingsService; _log = application.Logger; _canRunNewGame = true; }
internal static void Main(string[] args) { // setup internal state _zloApi = ZApi.Instance; _gameFactory = _zloApi.GameFactory; var logger = _zloApi.Logger; // configure logging logger.SetLogLevelFiltering(ZLogLevel.Debug | ZLogLevel.Warning | ZLogLevel.Error | ZLogLevel.Info); logger.LogMessage += (sender, messageArgs) => Console.WriteLine(messageArgs.Message); var connection = _zloApi.Connection; // configure api thread synchronization _zloApi.Configure(new ZConfiguration { SynchronizationContext = new SynchronizationContext() }); Console.WriteLine("Connecting to ZClient..."); // create connection var resetEvent = new ManualResetEvent(false); connection.ConnectionChanged += (sender, changedArgs) => resetEvent.Set(); connection.Connect(); // wait for connection resetEvent.WaitOne(); if (_zloApi.Connection.IsConnected) { Console.WriteLine("Connected\n"); // call async version of Main(...) MainAsync(args).GetAwaiter().GetResult(); } else { Console.WriteLine("Cannot connect to ZClient\n"); } Console.ReadKey(); }