public IBus CreateConsumerBus(string connectionStringKey, ConsumerRegistration consumers) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(connectionStringKey, () => DefaultConnection); var subscriptionPrefix = appSettings.RabbitMQ.SubscriptionPrefix; try { var bus = CreateBus(connectionStringKey, null); var dispatcher = new NoMagicAutoDispatcher(consumers); var autoSubscriber = new AutoSubscriber(bus, subscriptionPrefix) { AutoSubscriberMessageDispatcher = dispatcher }; var consumerAssemblies = consumers.GetAssemblies(); autoSubscriber.Subscribe(consumerAssemblies); Log.DebugFormat("Connected to RabbitMQ on {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); return bus; } catch (Exception e) { Log.ErrorFormat("Failed to create a bus for RabbitMQ with connectionstring: {0}", connectionString); Log.ErrorFormat("The failure was {0}", e.Message); throw; } }
public virtual IActionResult RegisterConsumer([FromRoute(Name = "game_id")][Required][Range(0, 2048)] int gameId, [FromBody] ConsumerRegistration consumerRegistration) => new GameRequestPipeline() .Game(gameId) .Compute(code: c => { JoinResponse response = c.Game.RegisterConsumer(consumerRegistration); if (response == null) { c.Response = StatusCode(410); } else { c.Response = new ObjectResult(response); } }) .ExecuteAction();
protected void Application_Start() { var pluginFolders = new List <string>(); var plugins = Directory.GetDirectories(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins")).ToList(); plugins.ForEach(s => { var di = new DirectoryInfo(s); pluginFolders.Add(di.Name); }); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Bootstrapper.Compose(pluginFolders); ConsumerRegistration.Register(); }
/// <summary> /// Register Consumers Add a consumer to create a *virtual* (*spectating*) player to consume events /// </summary> /// <exception cref="Tgm.Roborally.Api.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="gameId">The id of the game to interact with</param> /// <param name="consumerRegistration">Information about the joining consumer (optional)</param> /// <returns>Task of ApiResponse (JoinResponse)</returns> public async System.Threading.Tasks.Task <Tgm.Roborally.Api.Client.ApiResponse <JoinResponse> > RegisterConsumerAsyncWithHttpInfo(int gameId, ConsumerRegistration consumerRegistration = default(ConsumerRegistration)) { Tgm.Roborally.Api.Client.RequestOptions localVarRequestOptions = new Tgm.Roborally.Api.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; foreach (var _contentType in _contentTypes) { localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType); } foreach (var _accept in _accepts) { localVarRequestOptions.HeaderParameters.Add("Accept", _accept); } localVarRequestOptions.PathParameters.Add("game_id", Tgm.Roborally.Api.Client.ClientUtils.ParameterToString(gameId)); // path parameter localVarRequestOptions.Data = consumerRegistration; // make the HTTP request var localVarResponse = await this.AsynchronousClient.PostAsync <JoinResponse>("/games/{game_id}/consumers", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("RegisterConsumer", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Register Consumers Add a consumer to create a *virtual* (*spectating*) player to consume events /// </summary> /// <exception cref="Tgm.Roborally.Api.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="gameId">The id of the game to interact with</param> /// <param name="consumerRegistration">Information about the joining consumer (optional)</param> /// <returns>Task of JoinResponse</returns> public async System.Threading.Tasks.Task <JoinResponse> RegisterConsumerAsync(int gameId, ConsumerRegistration consumerRegistration = default(ConsumerRegistration)) { Tgm.Roborally.Api.Client.ApiResponse <JoinResponse> localVarResponse = await RegisterConsumerAsyncWithHttpInfo(gameId, consumerRegistration); return(localVarResponse.Data); }
/// <summary> /// Register Consumers Add a consumer to create a *virtual* (*spectating*) player to consume events /// </summary> /// <exception cref="Tgm.Roborally.Api.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="gameId">The id of the game to interact with</param> /// <param name="consumerRegistration">Information about the joining consumer (optional)</param> /// <returns>ApiResponse of JoinResponse</returns> public Tgm.Roborally.Api.Client.ApiResponse <JoinResponse> RegisterConsumerWithHttpInfo(int gameId, ConsumerRegistration consumerRegistration = default(ConsumerRegistration)) { Tgm.Roborally.Api.Client.RequestOptions localVarRequestOptions = new Tgm.Roborally.Api.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; var localVarContentType = Tgm.Roborally.Api.Client.ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = Tgm.Roborally.Api.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.PathParameters.Add("game_id", Tgm.Roborally.Api.Client.ClientUtils.ParameterToString(gameId)); // path parameter localVarRequestOptions.Data = consumerRegistration; // make the HTTP request var localVarResponse = this.Client.Post <JoinResponse>("/games/{game_id}/consumers", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("RegisterConsumer", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Register Consumers Add a consumer to create a *virtual* (*spectating*) player to consume events /// </summary> /// <exception cref="Tgm.Roborally.Api.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="gameId">The id of the game to interact with</param> /// <param name="consumerRegistration">Information about the joining consumer (optional)</param> /// <returns>JoinResponse</returns> public JoinResponse RegisterConsumer(int gameId, ConsumerRegistration consumerRegistration = default(ConsumerRegistration)) { Tgm.Roborally.Api.Client.ApiResponse <JoinResponse> localVarResponse = RegisterConsumerWithHttpInfo(gameId, consumerRegistration); return(localVarResponse.Data); }
public IBus CreateBus(string connectionStringKey, IWindsorContainer container) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(connectionStringKey, () => DefaultConnection); var subscriptionPrefix = appSettings.RabbitMQ.SubscriptionPrefix; try { Log.InfoFormat("Connecting to RabbitMQ via {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); var logger = new RabbitMQLogger(); var bus = RabbitHutch.CreateBus(connectionString, x => x.Register<IEasyNetQLogger>(p => logger)); var autoSubscriber = new AutoSubscriber(bus, subscriptionPrefix) { AutoSubscriberMessageDispatcher = new WindsorMessageDispatcher(container) }; var registration = new ConsumerRegistration(); var assemblies = registration.GetAssemblies(container); autoSubscriber.Subscribe(assemblies.ToArray()); autoSubscriber.SubscribeAsync(assemblies.ToArray()); Log.DebugFormat("Connected to RabbitMQ on {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); return bus; } catch (Exception e) { Log.ErrorFormat("Failed to create a bus for RabbitMQ with connectionstring: {0}", connectionString); Log.ErrorFormat("The failure was {0}", e.Message); throw; } }