@@ -6,7 +6,22 @@ namespace GameLovers.Services
66 /// Tags the interface as a <see cref="IGameCommand{TGameLogic}"/>
77 /// </summary>
88 public interface IGameCommandBase { }
9-
9+
10+ /// <summary>
11+ /// Contract for the command to be executed in the <see cref="ICommandService{TGameLogic}"/>.
12+ /// Implement this interface if you want logic to be executed ont he server
13+ /// </summary>
14+ /// <remarks>
15+ /// Follows the Command pattern <see cref="https://en.wikipedia.org/wiki/Command_pattern"/>
16+ /// </remarks>
17+ public interface IGameServerCommand < in TGameLogic > : IGameCommandBase where TGameLogic : class
18+ {
19+ /// <summary>
20+ /// Executes the command logic defined by the implemention of this interface
21+ /// </summary>
22+ void ExecuteLogic ( TGameLogic gameLogic ) ;
23+ }
24+
1025 /// <summary>
1126 /// Interface representing the command to be executed in the <see cref="ICommandService{TGameLogic}"/>.
1227 /// Implement this interface with the proper command logic
@@ -19,7 +34,7 @@ public interface IGameCommand<in TGameLogic> : IGameCommandBase where TGameLogic
1934 /// <summary>
2035 /// Executes the command logic defined by the implemention of this interface
2136 /// </summary>
22- void Execute ( TGameLogic gameLogic ) ;
37+ void Execute ( TGameLogic gameLogic , IMessageBrokerService messageBroker ) ;
2338 }
2439
2540 /// <summary>
@@ -42,16 +57,18 @@ public interface ICommandService<out TGameLogic> where TGameLogic : class
4257 public class CommandService < TGameLogic > : ICommandService < TGameLogic > where TGameLogic : class
4358 {
4459 private readonly TGameLogic _gameLogic ;
45-
46- public CommandService ( TGameLogic gameLogic )
60+ private readonly IMessageBrokerService _messageBroker ;
61+
62+ public CommandService ( TGameLogic gameLogic , IMessageBrokerService messageBroker )
4763 {
4864 _gameLogic = gameLogic ;
65+ _messageBroker = messageBroker ;
4966 }
50-
67+
5168 /// <inheritdoc />
5269 public void ExecuteCommand < TCommand > ( TCommand command ) where TCommand : IGameCommand < TGameLogic >
5370 {
54- command . Execute ( _gameLogic ) ;
71+ command . Execute ( _gameLogic , _messageBroker ) ;
5572 }
5673 }
5774}
0 commit comments