/// <summary> /// Register Extra call back for command /// </summary> /// <typeparam name="TCommand">Specified type of command</typeparam> /// <typeparam name="TReceiveType">Specified type of receive item</typeparam> /// <typeparam name="TSendType">Specified type of send item</typeparam> /// <param name="actionCallBack">Extra call back for command</param> /// <param name="callBackExecutePeriod">Specified type of execute</param> #region RegisterExtraCallBackForCommand public void RegisterExtraCallBackForCommand <TCommand, TReceiveType, TSendType>( Action <TReceiveType, TAccount, Guid, Action <TSendType, CommandSendType> > actionCallBack, EnumCallBackExecutePeriod callBackExecutePeriod) where TCommand : IG9CommandWithSend { CommandHandlerCallback.AddCallBackForCommand(typeof(TCommand).Name, actionCallBack, callBackExecutePeriod); }
/// <summary> /// Register Extra call back for command /// </summary> /// <typeparam name="TSendReceiveType">Specified type of send and receive item</typeparam> /// <param name="commandName">Specified command name</param> /// <param name="actionCallBack">Extra call back for command</param> /// <param name="callBackExecutePeriod">Specified type of execute</param> #region RegisterExtraCallBackForCommand public void RegisterExtraCallBackForCommand <TSendReceiveType>(string commandName, Action <TSendReceiveType, TAccount, Guid, Action <TSendReceiveType, CommandSendType> > actionCallBack, EnumCallBackExecutePeriod callBackExecutePeriod) { CommandHandlerCallback.AddCallBackForCommand(commandName, actionCallBack, callBackExecutePeriod); }
/// <summary> /// Add extra call back for command /// </summary> /// <typeparam name="TReceive">Specified receive item</typeparam> /// <typeparam name="TSendType">Specified send item</typeparam> /// <param name="commandName">Specified game name</param> /// <param name="actionCallBack">Specified action call back</param> /// <param name="callBackExecutePeriod">Specified type of period for call back</param> #region AddCallBackForCommand public void AddCallBackForCommand <TReceive, TSendType>(string commandName, Action <TReceive, TAccount, Guid, Action <TSendType, CommandSendType> > actionCallBack, EnumCallBackExecutePeriod callBackExecutePeriod) { // If command not exist return if (!CheckCommandExist(commandName)) { throw new Exception("Command not found!"); } // Func for call back EnumCallBackExecutePeriod ActionCallBackForCommand(object data, TAccount account, Guid id, Action <object, CommandSendType> sendAnswerWithReceiveRequestId) { actionCallBack?.Invoke((TReceive)data, account, id, (answerData, sendType) => { if (sendType == CommandSendType.Asynchronous) { account.SessionSendCommand.SendCommandByNameAsync(commandName, answerData, id); } else { account.SessionSendCommand.SendCommandByName(commandName, answerData, id); } }); return(callBackExecutePeriod); } // Add call back _accessToCommandDataTypeCollection[commandName.GenerateStandardCommandName(CommandSize)] .AddRegisterCallback(ActionCallBackForCommand); }