Assets.Scripts.Services.Communication.WebSocketService.RegisterCommand C# (CSharp) Method

RegisterCommand() public method

public RegisterCommand ( string commandName, Action callbackMethod, Type dtoType ) : void
commandName string
callbackMethod Action
dtoType System.Type
return void
        public void RegisterCommand(string commandName, Action<CommandDTO> callbackMethod, Type dtoType)
        {
            if (!registeredCommands.ContainsKey(commandName))
            {
                registeredCommands.TryAdd(commandName, new List<CommandRegistration>());
            }
            registeredCommands[commandName].Add(new CommandRegistration(callbackMethod, dtoType));
        }

Usage Example

 void Start()
 {
     webSocketService = FindObjectOfType<WebSocketService>();
     webSocketService.RegisterCommand(GameConfigUpdateDTO.COMMAND_NAME, GameConfigUpdateCallback, typeof(GameConfigUpdateDTO));
     webSocketService.RegisterCommand(ComboHitSequenceUpdateDTO.COMMAND_NAME, ComboHitSequenceUpdateCallback, typeof(ComboHitSequenceUpdateDTO));
     comboHitSequenceFactory = new ComboHitSequenceFactory();
     CreateRandomHitSequences();
 }
All Usage Examples Of Assets.Scripts.Services.Communication.WebSocketService::RegisterCommand